The Chapter3 & Chapter4 of this book tells you how to create a realistic app on the web through the lab.
That is really amazing when you finished yourself. I will show you how to make it as follows.
FIRST OF ALL, we need a plan of how to make an application, generally speaking, you can following the steps like this(as we did it in the lab1):
1. Create a database and table for the app (the email list)
2. Create and edit a web form for the customer
3. Create and edit a PHP script to handle the web form
To Finish the application, we should start with the table, actually, it all starts with a database.
step 1 :
what you have to do is to use these command line with MySQL :
CREATE DATABASE elvis_store
Then you need to create a table inside the database, just like we did in the lab1, but beofore you create tables, Please
make sure you have selected the database or you will get an ERROR. This command may help you with it :
USE elvis_store
Next you can create table(s) inside this database, table structure is based on your application, In this app you can design the table like this:
CREATE TABLE email_list ( first_name VARCHAR (20) , last_name VARCHAR (20) , email VARCHAR (60) );
It is quite simple, yeah ? Next we will move to step2:
step2 :
make a directory to store this application, you can name it lab2 or anything you want, and add some html files && css files to it :
/*** addemail.html ***/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Make Me Elvis - Add Email</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <img src="blankface.jpg" width="161" height="350" alt="" style="float:right" /> <img name="elvislogo" src="elvislogo.gif" width="229" height="32" border="0" alt="Make Me Elvis" /> <p>Enter your first name, last name, and email to be added to the <strong>Make Me Elvis</strong> mailing list.</p> <form method="post" action="addemail.php"> <label for="firstname">First name:</label> <input type="text" id="firstname" name="firstname" /><br /> <label for="lastname">Last name:</label> <input type="text" id="lastname" name="lastname" /><br /> <label for="email">Email:</label> <input type="text" id="email" name="email" /><br /> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html>
/*** style.css ***/
body, td, th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
If you run it on your apache Server , you will get a page like this :
Its just a simple form and serveral css. Very Simple. Now we have finished step2.
The only thing we need to notice is that this form‘s action = ‘addemail.php‘ which means it will send this form to the file on the Server.
lets move to the step3. you may probably know how to do it, yes create an edit addemail.php file on the Server.
Step3: