Workshop

 <  Day Day Up  >  

Quiz

1:

So that your program remembers long, multipage Web transactions, you need to use

  1. Databases and cookies

  2. Hidden HTML form fields

  3. Some combination of hidden HTML form fields, cookies, and databases

2:

Using an HTML <form> tag without an action attribute will

  1. Not work

  2. Cause the submit button to use the CGI program that originally generated the page

  3. Cause the submit button to reload the current page

3:

The survey program, as listed, has a small bug. What is it?

  1. print<<EOP; is not valid syntax in Listing 23.2.

  2. The HTML is not complete because it lacks <head> tags and such.

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

    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%

       

 <  Day Day Up  >  


SAMS Teach Yourself Perl in 24 Hours
Sams Teach Yourself Perl in 24 Hours (3rd Edition)
ISBN: 0672327937
EAN: 2147483647
Year: 2005
Pages: 241

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