Specifications

FIGURE 24.6
The member.php script checks that a user is logged in; retrieves and displays his bookmarks; and gives him
a menu of options.
We will now look at the login() and check_valid_user() functions a little more closely. The
login() function is shown in Listing 24.12.
LISTING 24.12 The login() Function from user_auth_fns.phpThis Function Checks a
Users Details Against the Database
function login($username, $password)
// check username and password with db
// if yes, return true
// else return false
{
// connect to db
$conn = db_connect();
if (!$conn)
return 0;
// check if username is unique
$result = mysql_query(“select * from user
where username=’$username’
and passwd = password(‘$password’)”);
if (!$result)
Building Practical PHP and MySQL Projects
P
ART V
516
30 7842 ch24 3/6/01 3:34 PM Page 516