
The code for the admin menu is shown in Listing 25.17.
LISTING 25.17 admin.php—This Script Authenticates the Administrator and Lets Her
Access the admin Functions
<?
// include function files for this application
require_once(“book_sc_fns.php”);
session_start();
if ($username && $passwd)
// they have just tried logging in
{
if (login($username, $passwd))
{
// if they are in the database register the user id
$admin_user = $username;
session_register(“admin_user”);
}
else
{
// unsuccessful login
do_html_header(“Problem:”);
echo “You could not be logged in.
You must be logged in to view this page.<br>”;
do_html_url(“login.php”, “Login”);
do_html_footer();
exit;
}
}
do_html_header(“Administration”);
if (check_admin_user())
display_admin_menu();
else
echo “You are not authorized to enter the administration area.”;
do_html_footer();
?>
This code probably looks familiar; it is similar to a script from Chapter 24. After the adminis-
trator reaches this point, she can change her password or log out—this code is identical to the
code in Chapter 24, so we will not cover it here.
Building a Shopping Cart
C
HAPTER 25
25
B
UILDING A
SHOPPING CART
577
31 7842 CH25 3/6/01 3:39 PM Page 577
Comentarios a estos manuales