Assignment 4: On-line Bookstore via CGI

Due November 15

You will modify the bookstore site that you created in an earlier assignment.

The web page shall contain three frames. The top 1/4 of the page (the title frame) should display a simple header that says, "X's Books" (where X is your name) in a very large font. The font should be a color other than black on a background that is other than white. The bottom 3/4 of the page will be split into two frames, the left of which comprises 1/3 of the remaining space and will hold navigational information. The right 2/3 (the information frame) will display information about the books.

The navigation frame will display at least three links corresponding to "science fiction", "technical reference", "biographies". You may add other links if you like. Clicking on any of these will display information in the information frame about at least two books that fit the given classification. I.e., clicking on "biographies" will display information about at least two biographies. This frame should use a different font and background color from the title frame. (The background color cannot be white.)

When the web page is first loaded, the information frame should be blank (a white background). Whenever one of the navigation links is selected, the information frame will list the appropriate books in an ordered list, using roman numeral numbering. Each element of this list will provide the title and author of the book, as well as a small image of the cover of the book.

In addition, there should be a small check box adjacent to each book, labelled "Order this", as well as buttons in the frame labelled "Add to Shopping Cart" and "View Shopping Cart" . Upon clicking on the latter, the information frame should change to a page generated by a CGI perl script:

The Shopping Cart Page

This page should display the title and authors of the "ordered" books in a table or list. Adjacent to each of these should be a textbox in which the user can enter the number of copies to order of each book (assume 1 as the default). There should be a line labelled "TOTAL ORDER" showing the prospective cost of purchasing the current shopping cart contents. This "shopping cart" page must have two buttons: "Update Cart" and "Proceed to Checkout". Clicking on the former should update the TOTAL ORDER line. If the user changes the number of copies of a book to zero, the Update Cart button should remove that entry from the table. Clicking on a "Proceed to Checkout" button from this page should generate a new page:

The Order Page

This page should show the order information: the titles ordered, their cost, and the number of each, as well as a GRAND TOTAL line. There should also be a mechanism for providing the user's name, address and means of payment. (See the popcorn.html and popcorn.pl example for hints on how to do this) in the information frame that details the cost to the user for the purchase. There should be "Complete Order" button that clears the shopping cart and sends the user back to the default shopping page.

Your system should use cookies to customize your site. Upon returning to the site, it should provide a "Welcome back, NAME" message in the navigation frame, where NAME is the name provided by the user when ordering books in a previous visit. In addition, when new books are ordered, the form elements on the Order Page should be pre-filled with the last values used by that user. I.e., the name, address, and method-of-payment fields should be the same as for the previous order.

You should implement your site on bobolink.acad.emich.edu, using the userid and password that you use with the homework submission system. (Though you should change your password ASAP!) Remember that your html files should go in ~/public_html, and that directory should contain a cgi-bin directory, in which you will place your Perl scripts. You must turn off write permissions for everyone else for these directories. Do this via the Unix command:

chmod og-w ~/public_html ~/public_html/cgi-bin

Remember, too, that your Perl scripts must be executable. Here's an example for how to do that:

chmod a+x ~/public_html/cgi-bin/myscript.pl

Submitting Your Page:

When you have completed the assignment, e-mail me the URL for your site. In addition, submit hardcopies of your html and Perl files at the beginning of class on the due date.

Hints:

Handling the cookies correctly can be tricky. You'll have to use a file on your web site to keep track of previous visitor's information.