Specifications
LISTING 24.4 do_html_header() Function from output_fns.php—This Function Outputs
the Standard Header That Will Appear on Each Page in the Application
function do_html_header($title)
{
// print an HTML header
?>
<html>
<head>
<title><?=$title?></title>
<style>
body { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
hr { color: #3333cc; width=300; text-align=left}
a { color: #000000 }
</style>
</head>
<body>
<img src=”bookmark.gif” alt=”PHPbookmark logo” border=0
align=left valign=bottom height = 55 width = 57>
<h1> PHPbookmark</h1>
<hr>
<?
if($title)
do_html_heading($title);
}
As you can see, the only logic in this function is to add the appropriate title and heading to the
page. The other functions we have used in login.php are similar. The function
display_site_info() adds some general text about the site; display_login_form() displays
the grey form shown in Figure 24.3; and
do_html_footer() adds a standard HTML footer to
the page.
(The advantages to isolating or removing HTML from your main logic stream are discussed in
Chapter 22, “Using PHP and MySQL for Large Projects.” We will use the function API
approach here, and a template-based approach in the next chapter for contrast.)
Looking at Figure 24.3, you can see that there are three options on this page—the user can reg-
ister, log in if they have already registered, or reset their password if they have forgotten it. To
implement these modules we will move on to the next section, user authentication.
Implementing User Authentication
There are four main elements to the user authentication module: user registration, login and
logout, changing passwords, and resetting passwords. We will look at each of these in turn.
Building Practical PHP and MySQL Projects
P
ART V
506
30 7842 ch24 3/6/01 3:34 PM Page 506










