Specifications

else
echo “Could not delete “.htmlspecialchars($url).”.<br>”;
}
}
else
echo “No bookmarks selected for deletion”;
}
// get the bookmarks this user has saved
if ($url_array = get_user_urls($valid_user));
display_user_urls($url_array);
display_user_menu();
do_html_footer();
?>
We begin this script by performing the usual validations. When we know that the user has
selected some bookmarks for deletion, we delete them in the following loop:
foreach($del_me as $url)
{
if (delete_bm($valid_user, $url))
echo “Deleted “.htmlspecialchars($url).”.<br>”;
else
echo “Could not delete “.htmlspecialchars($url).”.<br>”;
}
As you can see, the delete_bm() function does the actual work of deleting the bookmark from
the database. This function is shown in Listing 24.25.
LISTING 24.25 delete_bm() Function in url_fns.phpThis Function Deletes a Single
Bookmark from a Users List
function delete_bm($user, $url)
{
// delete one URL from the database
if (!($conn = db_connect()))
return false;
// delete the bookmark
if (!mysql_query( “delete from bookmark
where username=’$user’ and bm_url=’$url’”))
return false;
return true;
}
Building User Authentication and Personalization
C
HAPTER 24
24
AUTHENTICATION
AND
PERSONALIZATION
531
LISTING 24.24 Continued
30 7842 ch24 3/6/01 3:34 PM Page 531