Specifications

First, we check whether the user has come from the front pagethat is, whether he has just
filled in the login formand try to log them in as follows:
if ($username && $passwd)
// they have just tried logging in
{
if (login($username, $passwd))
{
// if they are in the database register the user id
$valid_user = $username;
session_register(“valid_user”);
}
You can see that we are trying to log him in using a function called login(). We have defined
this in the user_auth_fns.php library, and well look at the code for it in a minute.
If he is logged in successfully, we register his session as we did before, storing the username in
the session variable $valid_user.
If all went well, we then show the user the members page:
do_html_header(“Home”);
check_valid_user();
// get the bookmarks this user has saved
if ($url_array = get_user_urls($valid_user));
display_user_urls($url_array);
// give menu of options
display_user_menu();
do_html_footer();
This page is again formed using the output functions. You will notice that we are using several
other new functions. These are check_valid_user(), from user_auth_fns.php;
get_user_urls(), from url_fns.php; and display_user_urls() from output_fns.php. The
check_valid_user() function checks that the current user has a registered session. This is
aimed at users who have not just logged in, but are mid-session. The get_user_urls() func-
tion gets a users bookmarks from the database, and display_user_urls() outputs the book-
marks to the browser in a table. We will look at check_valid_user() in a moment and at the
other two in the section on bookmark storage and retrieval.
The member.php script ends the page by displaying a menu with the display_user_menu()
function.
Some sample output as displayed by member.php is shown in Figure 24.6.
Building User Authentication and Personalization
C
HAPTER 24
24
AUTHENTICATION
AND
PERSONALIZATION
515
30 7842 ch24 3/6/01 3:34 PM Page 515