13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Examining the Script Architecture<br />

659<br />

Listing 29.2<br />

Continued<br />

//*****************************************************************************<br />

// Stage 2: headers<br />

// Send the HTML headers <strong>and</strong> menu bar appropriate to current action<br />

//*****************************************************************************<br />

if($action) {<br />

// display header with application name <strong>and</strong> description of page or action<br />

do_html_header($_SESSION['auth_user'], "Warm Mail - ".<br />

format_action($action),<br />

$_SESSION['selected_account']);<br />

} else {<br />

// display header with just application name<br />

do_html_header($_SESSION['auth_user'], "Warm Mail",<br />

$_SESSION['selected_account']);<br />

}<br />

display_toolbar($buttons);<br />

//*****************************************************************************<br />

// Stage 3: body<br />

// Depending on action, show appropriate main body content<br />

//*****************************************************************************<br />

//display any text generated by functions called before header<br />

echo $status;<br />

if(!check_auth_user()) {<br />

echo "You need to log in";<br />

if(($action) && ($action!='log-out')) {<br />

echo " to go to ".format_action($action);<br />

}<br />

echo ".";<br />

display_login_form($action);<br />

} else {<br />

switch ($action) {<br />

// if we have chosen to setup a new account, or have just added or<br />

// deleted an account, show account setup page<br />

case 'store-settings':<br />

case 'account-setup':<br />

case 'delete-account':<br />

display_account_setup($_SESSION['auth_user']);<br />

break;<br />

case 'send-message':

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!