So that your program remembers long, multipage Web transactions, you need to use
Databases and cookies
Hidden HTML form fields
Some combination of hidden HTML form fields, cookies, and databases
2:
Using an HTML <form> tag without an action attribute will
Not work
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?
print<<EOP; is not valid syntax in Listing 23.2.
The HTML is not complete because it lacks <head> tags and such.
The survey doesn't print its results.
Answers
A1:
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: