This project must be done individually. No copying is permitted. The goal of this project is to learn server-side web programming using PHP. More specifically, you will develop a bookstore web application where customers can buy books listed by the isbndb web service.
For this project, you will use the Omega web server. Login to omega.uta.edu. Please call UTA OIT if you have problems with your omega account. Look at your path using the unix command pwd. For example, if your username is xyz1234, you will see:
/home/x/xy/xyz1234In the following, change the path /home/x/xy/xyz1234 to your own path. Then, you do the following:
cd public_html wget http://lambda.uta.edu/cse5335/project2.tgz tar xfz project2.tgz cd project2Then edit the file .htaccess (note: it starts with a dot) inside the project2 directory using your favorite editor (vi, emacs, etc) and change the line
AuthUserFile /home/x/xy/xyz1234/public_html/project2/.htpasswdto point to your own path. Then do:
htpasswd .htpasswd xyz1234(use your username instead of xyz1234). It will ask you for a password twice. This is the password you use when you run your PHP scripts on a browser. It already contains a password for the GTA; so the GTA can run the script of any student but you can only run your own script. For this project, you should put your PHP files in the project2 directory. Don't put PHP scripts in a cgi-bin directory. You can test your setup on your web browser by using the URL address:
http://omega.uta.edu/~xyz1234/project2/buy.php(use your username instead of xyz1234). Note that if a script doesn't require GET/POST parameters, then you can test it by running it on omega using php. For example, php buy.php
The following are tutorials on PHP. Use them as a reference only.
<?php session_start(); if (!isset($_SESSION['count'])) $_SESSION['count'] = 0; $_SESSION['count']++; print 'you have visited ' . $_SESSION['count'] . ' times'; ?>
You will develop a trivial web application that allows customers to buy books. You need to reverse-engineer my PHP script:
http://lambda.uta.edu/cgi-bin/php/buy.phpby filling out its forms and by looking at the HTML source that is generated by this script. Your task is to modify your own buy.php script in your public_html/project2 directory on Omega to make it behave similarly to my buy.php.
You will use the ISBNDB web service to search for books. Read the ISBN database remote access API description. To use this web service, you will need this access key. We are interested only in books sold by amazon.com (that is, the store_id must be equal to amazon). The results of a search may come in multiple pages, but we will only use the first page. That is, we will use only the books from the first page that have a valid price from amazon.com.
You need to use $_SESSION to store the shopping basket (the list of bought books). For each bought book, you store the ISBN, the amazon price, and the info, which takes the form 'book authors: book title'.
Your PHP script must be able to handle the following query strings:
buy.php?search=elmasriThis should produce the web service request https://isbndb.com/api/books.xml?access_key=xxxxxx&index1=full&results=prices&value1=elmasri.
buy.php?isbn=0805317554&info=Ramez+Elmasri%2C+Shamkant+B.+Navathe%3A+Fundamentals+of+database+systems&price=19.98where isbn is the book ISBN and info is the 'book authors: book title'.
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.
Important: On top of your buy.php file, write the URL on Omega to use to run your program (eg. http://omega.uta.edu/~xyz1234/project2/buy.php). Use the form below to submit your buy.php file. You may submit your file as many times as you like, but only the most recently submitted file will be retained and evaluated.
Last modified: 02/16/10 by Leonidas Fegaras