Project 2
PHP Scripting

Due on Wednesday February 13 before midnight


This project must be done individually. No copying is permitted. The goal of this project is to learn server-side web programming with database connectivity using PHP. More specifically, you will develop a bookstore web application where customers can buy books listed in a database.


For this project, you will use the Omega web server. Login to Please call UTA OIT if you have problems with your omega account. Look at your path using the command pwd. For example, if your username is smith, you will see:

In the following, change the path /home/s/sm/smith to your own path. Create the directory public_html if doesn't exist. Then do:
cd public_html
mkdir project2
chmod 711 project2
cd project2
Then create a file .htaccess (note: it starts with a dot) inside the project2 directory with the following content:
AuthType Basic
AuthName "Running Project2"
AuthUserFile /home/s/sm/smith/public_html/project2/.htpasswd
require valid-user
(of course, change /home/s/sm/smith to your own path). Then create the password file using:
htpasswd -c .htpasswd smith
(use your username instead of smith). It will ask you for a password twice. This is the password you use when you run your PHP scripts on a browser. For this project, you should put all your PHP and HTML files in the project2 directory. Don't put PHP scripts in a cgi-bin directory. You can test your setup by using the following PHP file test.php inside your project2 directory.
<?php print "Hello!"; ?>
For user smith, you can run it using:

You can work on mySQL on Omega using the web site You must login using your omega username and your default password (the one that you use when you reset your password). Please call OIT if you have forgotten your default password. Then you click on the database that has the same name as your username and create your tables. There is online documentation on this web page, but basically the GUI is easy to use without reading any manual. This web site allows you to query, insert, delete, and update data.


The following web pages contain two tutorials on PHP. Use them as a reference only.

Project Requirements

You should create two PHP scripts: buy.php (the startup script) and checkout.php. The web page generated by buy.php should have the following components:

When the customer provides an author name in buy.php and pushes the search button to search for more books, she gets the same buy.php page but with new searched books along with the selected books from the previous page. The checkout.php page displays the selected books, their prices, and the total price.

For this project, assume that a book has only one author. You need to store the books in the mySQL database. You should insert at least 20 books. The selected books in each session should be stored as session data in the PHP vector $_SESSION.

Note: Like in the first project, you should not use any tool that generates code. You only allowed to use a text editor to write your scripts.

What to Submit

New: Please also submit a Readme.txt file that contains the following information:

URL on Omega:
htaccess username:
htaccess password:
Some book authors:
where URL on Omega is the URL the GTA should use to run your program (eg., htaccess username and password are those needed for the GTA to login to your application, and Some book authors is a list of authors from your database for the GTA to use.

On the omega mySQL web page, select Export, then select SQL (the default) and "Save as file", and push Go to create a .sql file with your schema and data. Use the form below to submit your Readme.txt, PHP and .sql files. You may submit each file as many times as you like, but only the most recently submitted file will be retained and evaluated.

Submit this file:

Last modified: 02/08/08 by Leonidas Fegaras