13.09.2016 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Setting Up the Database<br />

655<br />

Table 29.1 Files in the Warm Mail Application<br />

Name Type Description<br />

index.php Application The main script that runs the entire application<br />

include_fns.php Functions Collection of include files for this application<br />

data_valid_fns.php Functions Collection of functions for validating input data<br />

db_fns.php Functions Collection of functions for connecting to the mail<br />

database<br />

mail_fns.php Functions Collection of email-related functions for opening<br />

mailboxes, reading mail, <strong>and</strong> so on<br />

output_fns.php Functions Collection of functions for outputting HTML<br />

user_auth_fns.php Functions Collection of functions for authenticating users<br />

create_database.sql SQL SQL to set up the book_sc database <strong>and</strong> set up a<br />

user<br />

Let’s look at the application now.<br />

Setting Up the Database<br />

The database for Warm Mail is fairly simple because it doesn’t actually store any of the<br />

emails.<br />

You need to store users of the system. For each user, you need to store the following<br />

fields:<br />

n<br />

n<br />

n<br />

n<br />

username—The user’s preferred username for Warm Mail<br />

password—The user’s preferred password for Warm Mail<br />

address—The user’s preferred email address, which will appear in the From field<br />

of emails he sends from the system<br />

displayname—The “human-readable” name that the user would like displayed in<br />

emails from him to others<br />

You also need to store each account that users would like to check with the system. For<br />

each account, you need to store the following information:<br />

n username—The Warm Mail user who this account belongs to.<br />

n server—The machine on which the account resides; for example, localhost,<br />

mail.tangledweb.com.au, or another domain.<br />

n port—The port to connect to when using this account. Usually, it is 110 for<br />

POP3 servers <strong>and</strong> 143 for IMAP servers.<br />

n type—The protocol used to connect to this server, either POP3 or IMAP.<br />

n remoteuser—The username for connecting to the mail server.<br />

n remotepassword—The password for connecting to the mail server.<br />

n accountid—A unique key for identifying accounts.

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

Saved successfully!

Ooh no, something went wrong!