Specifications
The SQL to create this database, and to create a user for connecting to the database from the
Web, is shown in Listing 24.1. You should edit it if you plan to use it on your system—change
the user’s password to something more secure!
Building User Authentication and Personalization
C
HAPTER 24
24
AUTHENTICATION
AND
PERSONALIZATION
503
username passwd email
laura 7cbf26201e73c29b laura@tangledweb.com.au
luke 1fef10690eeb2e59 luke@tangledweb.com.au
username
user
bookmark
bm_URL
laura http://slashdot.org
laura http://php.net
FIGURE 24.2
Database schema for the PHPBookmark system.
LISTING 24.1 bookmarks.sql—SQL File to Set Up the Bookmark Database
create database bookmarks;
use bookmarks;
create table user (
username varchar(16) primary key,
passwd char(16) not null,
email varchar(100) not null
);
create table bookmark (
username varchar(16) not null,
bm_URL varchar(255) not null,
index (username),
index (bm_URL)
);
grant select, insert, update, delete
on bookmarks.*
to bm_user@localhost identified by ‘password’;
You can set up this database on your system by running this set of commands as the root
MySQL user. You can do this with the following command on your system’s command line:
mysql -u root -p < bookmarks.sql
30 7842 ch24 3/6/01 3:34 PM Page 503










