Specifications
db_fns.php Functions to connect to the database
user_auth_fns.php Functions for user authentication
url_fns.php Functions for adding and deleting bookmarks and for mak-
ing recommendations
output_fns.php Functions that format output as HTML
bookmark.gif Logo for PHPBookmark
We will begin by implementing the MySQL database for this application as it will be required
for virtually all the other functionality to work.
Then we will work through the code in the order it was written, starting from the front page,
going through the user authentication, to bookmark storage and retrieval, and finally to recom-
mendations. This order is fairly logical—it’s just a question of working out the dependencies
and building first the things that will be required for later modules.
Building Practical PHP and MySQL Projects
P
ART V
502
TABLE 24.1 Continued
Filename Description
For the code in this project to work as written, you will need to have switched on
magic quotes. If you have not done this, then you will need to
addslashes() to data
being inserted to the MySQL database, and
stripslashes() from data retrieved from
the database. We have used this as a useful shortcut.
NOTE
Implementing the Database
We only require a fairly simple schema for the PHPBookmark database. We need to store users
and their email addresses and passwords. We also need to store the URL of a bookmark. One
user can have many bookmarks, and many users can register the same bookmark. We therefore
have two tables, user and bookmark, as shown in Figure 24.2.
The user table will store the user’s username (which is the primary key), password, and email
address.
The bookmark table will store username and bookmark (bm_URL) pairs. The username in this
table will refer back to a username from the user table.
30 7842 ch24 3/6/01 3:34 PM Page 502










