Specifications
This is the default behavior for the application. With no $action chosen yet, and no login
details supplied, we will execute the following parts of the code.
In the preprocessing stage, we execute the following code:
include (‘include_fns.php’);
session_start();
These lines start the session that will be used to keep track of the $auth_user and
$selected_account session variables, which we’ll come to later on.
To save work when customizing the user interface, the buttons that appear on the toolbar are
controlled by an array. We declare an empty array,
$buttons = array();
and set the buttons that we want on the page:
$buttons[0] = ‘view-mailbox’;
$buttons[1] = ‘new-message’;
$buttons[2] = ‘account-setup’;
For the header stage, we print a plain vanilla header:
do_html_header($auth_user, “Warm Mail”, $selected_account);
...
display_toolbar($buttons);
This code prints the title and header bar, and then the toolbar of buttons you can see in Figure
27.2. These functions can be found in the output_fns.php function library, but as you can eas-
ily see their effect in the figure, we won’t go through them here.
Now we come to the body of the code:
if(!check_auth_user())
{
echo “<P>You need to log in”;
if($action&&$action!=’log-out’)
echo “ to go to “.format_action($action);
echo “.<br><br>”;
display_login_form($action);
}
The check_auth_user() function is from the user_auth_fns.php library. We have used very
similar code in some of the previous projects—it checks if the user is logged in. If he is not,
which is the case here, we will show him a login form, which you can see in Figure 27.2. We
draw this form in the display_login_form() function from output_fns.php.
If the user fills in the form correctly and presses the Log In button, he will see the output
shown in Figure 27.3.
Building Practical PHP and MySQL Projects
P
ART V
630
33 7842 CH27 3/6/01 3:41 PM Page 630










