EXERCISE C.2


1:

Creating Forms ”HTML

  1. 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.

    graphics/ap03fig41.jpg

  2. 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.

  3. Test your file in a browser.

  4. The CGI script will print the value of the QUERY_STRING environment variable.

2:

Processing Forms ” CGI

  1. 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.

  2. Redesign the form to include the POST method. The program will test which method was used and call the parse function.

  3. 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.

  4. 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.

3:

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.

4:

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.

graphics/ap03fig42.jpg

5:

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.




JavaScript by Example
JavaScript by Example (2nd Edition)
ISBN: 0137054890
EAN: 2147483647
Year: 2003
Pages: 150
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net