Specifications

//*****************************************************************************
// Stage 1: pre-processing
// Do any required processing before page header is sent
// and decide what details to show on page headers
//*****************************************************************************
include (‘include_fns.php’);
session_start();
$buttons = array();
//append to this string if anything processed before header has output
$status = ‘’;
// need to process log in or out requests before anything else
if($username||$password)
{
if(login($username, $passwd))
{
$status .= “<p>Logged in successfully.<br><br><br><br><br><br>”;
$auth_user = $username;
session_register(“auth_user”);
}
else
{
$status .= “<p>Sorry, we could not log you in with that
username and password.<br><br><br><br><br><br>”;
}
}
if($action == ‘log-out’)
{
session_destroy();
unset($action);
unset($auth_user);
}
//need to process choose, delete or store account before drawing header
switch ( $action )
{
case ‘delete-account’ :
{
delete_account($auth_user, $account);
break;
}
case ‘store-settings’ :
{
Building Practical PHP and MySQL Projects
P
ART V
624
LISTING 27.2 Continued
33 7842 CH27 3/6/01 3:41 PM Page 624