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.

Logging In <strong>and</strong> Out<br />

663<br />

The four main sections of the script are as follows:<br />

1. You do some processing that must take place before you send the page header to<br />

the browser, such as starting the session, executing any preprocessing for the action<br />

the user has selected, <strong>and</strong> deciding what the headers will look like.<br />

2. You process <strong>and</strong> send the appropriate headers <strong>and</strong> menu bar for the action the user<br />

has selected.<br />

3. You choose which body of the script to execute, depending on the selected action.<br />

The different actions trigger different function calls.<br />

4. You send the page footers.<br />

If you look briefly through the code for the script, you will see that these four sections<br />

are marked with comments.<br />

To underst<strong>and</strong> this script fully, let’s walk through actually using the site action by action.<br />

Logging In <strong>and</strong> Out<br />

When a user loads the page index.php, he will see the output shown in Figure 29.2.<br />

Figure 29.2<br />

The login screen for Warm Mail asks for a username <strong>and</strong> password.

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

Saved successfully!

Ooh no, something went wrong!