Create a Web page called Stirbucks that contains a form to order coffee, similar to the order form in Figure C.41.
Figure C.41. The Stirbucks Web page order form.
In the action attribute of the initial <FORM> tag, specify a URL that directs the server to a CGI script using the default GET method.
Test your file in a browser.
The CGI script will print the value of the QUERY_STRING environment variable.
Processing Forms ” CGI
Write a CGI script that will send back to the user an HTML page that thanks him for his order and tells him the coffee he selected will be delivered to his shipping address. Use the GET method. After getting the information from the form, write your own fuction to parse the input.
Redesign the form to include the POST method. The program will test which method was used and call the parse function.
Create a DBM file that keeps a list of the e-mail addresses submitted. When a user submits an order, his e-mail address will be listed in the DBM file. Make sure there are no duplicates. Design a function to do this.
The CGI script will handle e-mail. Send e-mail to yourself confirming the information that was submitted. Design another function to handle e-mail.
Rewrite the Stirbucks program so that the HTML form and the CGI script are in one CGI program created with the CGI .pm module. Use the function-oriented style.
Add to the Stirbucks program a cookie that will save the user's preferences so that each time he orders coffee, he will get a free sweet. If he doesn't state a preference, he will get a bagel with his coffee. The bagel or the alternate choice for a free sweet is saved in a Netscape cookie. The cookie should not expire for 1 week. (See Figure C.42.)
Figure C.42. Cookie output.
Write a CGI script (with the CGI .pm module) that will replace the ATM script you wrote in Chapter 11. The new CGI script will provide a form in the browser that will produce a menu of items; that is, deposit, withdraw, balance, etc. Use the object-oriented CGI methods to create the HTML form. In the same script, the param function will check which selection was checked, and, based on the selection, the appropriate method will be called from Checking.pm . After the form has been filled out and submitted, the results of processing will appear on the same page.