
ISM 4480 Electronic Commerce
Assignment 4: Working with Databases
In this assignment, you will extend the pizza order entry web site you designed in Assignments 2 and 3.
You will connect the order entry form in pizza1.htm (created in Assignment 3) to new PHP page
pizza4.php, which will insert all order details in the “pizza” database (a MySQL database) hosted on the
infosys server, and display a confirmation message.
You do not need to create your own database for this assignment. You can use the pizza database on the
infosys server, which is available to the entire class. The schema for this database is provided on the next
page.
To complete this assignment, you will need to use the SQL insert statement, with appropriate database
connectivity. All code required for connecting to and inserting new records into the pizza database is
provided in the PHP handout. However, because my sample program was created only for one pizza only
and your assignment is for 50 pizzas, you will have to modify the SQL string to enter all of your order
details. The only challenging part of this assignment is creating the right SQL string. If the SQL string is
incorrect, you will see an error message while trying to run it. To be sure that your program is working
correctly, run the PHP page display_orders.php from the PHP examples handout. If the pizza order you
just added was inserted properly, you should see this record toward the bottom of the displayed records.
A couple of issues about the pizza database that are worth noting:
1. You cannot (and should not) enter any data in the OrderNum and OrderDate fields. OrderNum is
an Auto_Increment field meaning that MySQL automatically enters a unique value into that field
(which is OrderNum for the previous order plus one) whenever a new record is being inserted.
OrderDate is a Timestamp field, meaning that MySQL automatically inserts the system date/time into
that field. You are not allowed to change either of these two values.
2. OrderAmount is the total price for your entire pizza order (for up to 50 pizzas). If the code for
calculating the total order amount (from the previous assignment) is working, you can insert that data
in the OrderAmount field in the database, else you can skip entering this field. You don’t need your
Assignment 3 to work for you to complete this assignment.
3. Don’t enter anything into the Delivered field. It is a binary field that automatically defaults to 0,
meaning that the pizza order is undelivered (as it is entered). In the next assignment, we will see how
to update this value to 1, and use it to track delivered and undelivered orders.
The deliverables to be submitted are:
1. Printout of the code in pizza4.php page.
2. Output of the display_orders.php page showing a pizza order that you entered with your own first
and last name (not all orders in the table, but only the last page showing your own order).
3. Upload all files to your assigned ecxx directory. Include your name and ecxx account as
comment statements at the top of the page.
If you need help with specific PHP or SQL commands, search Google before approaching me for
assistance. The following two websites are also very helpful:
SQL: http://www.w3schools.com/sql/
PHP: http://www.w3schools.com/PHP/default.asp