Workshop
Quiz
1: | So that your program remembers long, multipage Web transactions, you need to use
Some combination of hidden HTML form fields, cookies, and databases
| 2: | Using an HTML <form> tag without an action attribute will
Cause the submit button to use the CGI program that originally generated the page Cause the submit button to reload the current page
| 3: | The survey program, as listed, has a small bug. What is it?
The HTML is not complete because it lacks <head> tags and such. The survey doesn't print its results.
|
AnswersA1:
| Either b or c. You can use just hidden HTML fields or just cookies. Using just a database won't quite work. | A2:
| b. Reloading the current page would just erase all the current form answers. Without an action attribute, the <form> tag uses the URL of the current page for the submission URL. | A3:
| b. print<<EOP; is certainly valid syntax, called a here document. Choice c is not correct because the program wasn't designed that way (see the "Activities" section). |
Activities
Write a short CGI program to display the results of the survey program. Possibly build a table to display them like this: Cat/Dog | Own One? | Nocturnal | Clothes | Castaway | Traveler | Risky? |
---|
cat | no | yes | casual | Professor | yes | yes | neither | goldfish | no | business | Skipper | no | no | dog | yes | no | casual | Mary Ann | yes | yes |
For an additional challenge, write a CGI program to summarize the survey results like this: Cat/Dog Personality: | Cat 40% | Dog 45% | Neither 15% | | Own that pet: | Cat 20% | Dog 15% | Goldfish 30% | None 35% | Night Person? | Yes 35% | No 40% | | |
|