Specifications

Look back at the script in Listing 27.2. This time around because of the value of $action,we
get different behavior.
We get a slightly different header, as follows:
do_html_header($auth_user, “Warm Mail - “.
format_action($action), $selected_account);
More importantly, we get a different body, as follows:
case ‘store-settings’ :
case ‘account-setup’ :
case ‘delete-account’ :
{
display_account_setup($auth_user);
break;
}
This is the typical pattern: Each command calls a function. In this case, we call the
display_account_setup() function. The code for this function is shown in Listing 27.3.
LISTING 27.3 display_account_setup() Function from output_fns.phpFunction to Get
and Display Account Details
function display_account_setup($auth_user)
{
//display empty ‘new account’ form
display_account_form($auth_user);
$list = get_accounts($auth_user);
// display each stored account
foreach($list as $key => $account)
{
// display form for each accounts details.
// note that we are going to send the password for all accounts in the HTML
// this is not really a very good idea
display_account_form($auth_user, $account[‘accountid’], $account[‘server’],
$account[‘remoteuser’],
$account[‘remotepassword’], $account[‘type’],
$account[‘port’]);
}
}
When we call this function, it displays a blank form to add a new account, followed by editable
forms containing each of the users current email accounts. The
display_account_form()
Building a Web-Based Email Service
C
HAPTER 27
27
BUILDING A
WEB-BASED
EMAIL
SERVICE
633
33 7842 CH27 3/6/01 3:41 PM Page 633