February 2004
S M Tu W Th F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
^ASSIGNED
15 16 17 18 19 20 21
^DUE
22 23 24 25 26 27 28
As always, this assignment is done on your own. You may seek help from
the TA's or the instructor, but don't expect more than hints and a
re-hashing of the lab and lecture material.
However, in this lab, I won't fault you for looking at other people's cgi source as they post their programs. I didn't even bother to run my similar-signature program on your calculators for hw1 because I'm not too concerned about it. I'm much more concerned that people acquire the basic UNIX and gawk skills. CGI debugging is enough of a challenge once you start doing fancy things with files and shell commands, even if you know what you are doing. I just want to make sure I have individual grades assigned to each person this semester, so I want you to do your own work. Outright plagiarism is still very, very bad. But if you need hints, well, you might notice that I have not made much of an effort to have the fast people lock up their early solutions.
You are to design a web page which is an ordering form for a bunch of things, of your choosing. There should be at least four separate classes of things that can be ordered, and there should be an available quantity of each. In the past, students in web design have done ordering form pages for me using Charlie's Angels swag, skiing equipment, photo equipment, medieval torture devices, and Wonders of the World (the number of pyramids in stock was quite limited). This means you must have a file on the server which lists the inventory amounts and prices for each of the items. You can choose the file format, but it should be human-readable, e.g.
Pikachu 10.00 156 Bulbasaur 25.50 12 Squirtle 18.95 2and it would be very nice if it supported complicated text, e.g., multi-word item names, and an optional description field (a fourth field). If you want to add an image name, a fifth field, to each line, go ahead.
In order to be a shopping cart, you must display what has been currently ordered IN ADDITION to what might next be added to the order. You must calculate a total price of the items currently on order. You must provide some way of removing items from the cart, or equivalently, changing the number of items on order. Finally, you must make sure that you do not let them order more than the current number in stock. I don't care whether you revise their requested number down, or whether you issue an error and ignore the request.
In order to keep track of the order, you have your choice. You may use cookies (boo). You may use a session ID and keep the order on the server in a file (semi-boo). Or you may use data in hidden input fields in the form that you generate (semi-yea!).
How do you get an A? Well, tackle this problem: Suppose two people are ordering at the same time. One wants two Squirtles, and so does the other. I want you to think about how to reduce the inventory level temporarily, as someone starts ordering items. Obviously there are many issues here, and I am supposing you don't have the knowledge (locking) you need in order to address them. Also obvious is that it's not clear an ordering system should let anyone drop the inventory levels with an incomplete order. But go ahead and implement some sort of partial solution to this problem and we'll see what you were able to solve and what possible problems remain. Do not go to PHP and start making SQL calls -- I want you to think about synchronization, atomicity, and locking so that you learn something besides GAWK, UNIX, and POKEMON (the eternal golden triangle?) in this exercise.