Specifications
Choosing one of the options in the SELECT activates the select_account event. If you look at
the URL in Figure 27.5, you can see this appended to the end of the URL, along with the
account ID of the chosen account.
This has two effects. First, in the preprocessing stage of index.php, the chosen account will be
stored in the session variable $selected_account, as follows:
case ‘select-account’ :
{
// if have chosen a valid account, store it as a session variable
if($account&&account_exists($auth_user, $account))
{
$selected_account = $account;
session_register(‘selected_account’);
}
}
Second, when the body stage of the script is executed, the following code will be executed:
case ‘select-account’ :
case ‘view-mailbox’ :
{
// if mailbox just chosen, or view mailbox chosen, show mailbox
display_list($auth_user, $selected_account);
break;
}
As you can see, we take the same action here as if the user had chosen the View Mailbox
option. We’ll look at that next.
Viewing Mailbox Contents
Mailbox contents can be viewed with the display_list() function. This displays a list of all
the messages in the mailbox. The code for this function is shown in Listing 27.8.
LISTING 27.8 display_list() Function from output_fns.php—Function to Display All
Mailbox Messages
function display_list($auth_user, $accountid)
{
// show the list of messages in this mailbox
global $table_width;
if(!$accountid)
{
Building Practical PHP and MySQL Projects
P
ART V
640
33 7842 CH27 3/6/01 3:41 PM Page 640










