13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

656 Chapter 29 Building a <strong>Web</strong>-Based Email Service<br />

You can set up the database for this application by running the SQL shown in<br />

Listing 29.1.<br />

Listing 29.1<br />

create database mail;<br />

use mail;<br />

create_database.sql—SQL to Create the Mail Database<br />

create table users<br />

(<br />

username char(16) not null primary key,<br />

password char(40) not null,<br />

address char(100) not null,<br />

displayname char(100) not null<br />

);<br />

create table accounts<br />

(<br />

username char(16) not null,<br />

server char(100) not null,<br />

port int not null,<br />

type char(4) not null,<br />

remoteuser char(50) not null,<br />

remotepassword char(50) not null,<br />

accountid int unsigned not null auto_increment primary key<br />

);<br />

grant select, insert, update, delete<br />

on mail.*<br />

to mail@localhost identified by ‘password’;<br />

Remember that you can execute this SQL by typing<br />

mysql -u root -p < create_database.sql<br />

You need to supply your root password.You also should change the password for the<br />

mail user in create_database.sql <strong>and</strong> in db_fns.php before running it.<br />

On the CD-ROM, we provided an SQL file called populate.sql. In this application,<br />

we do not create a user registration or administration process.You can add one yourself if<br />

you want to use this software on a larger scale, but if you want it for personal use, you<br />

will just need to insert yourself into the database.The populate.sql script provides a<br />

template for doing this, so you can insert your details into it <strong>and</strong> run it to set yourself up<br />

as a user.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!