5) Add a checkbox to the form (such as "Do you want milk? Yes/No") and a text area where customers can type in what kind of cake they would like to order. Change your cgi script so that it includes these in its reply, such as "you requested tea with milk", "sorry we are out of chocolate cake". The checkbox and text area must have distinct names in the form. Their parameters are retrieved in the cgi file by using the "param()" function. #!/usr/local/bin/perl use CGI qw(:standard -debug); print header(); print " Tea is served

Tea


"; my $drink = param("drink"); my $milk = param("milk"); my $cake = param("cake"); if ($drink eq "tea") {print "You requested tea";} elsif ($drink eq "coffee"){print "You requested coffee";} elsif ($drink eq "hot chocolate"){print "You requested hot chocolate";} else {print "An error occurred.";} if ($milk eq "yes") {print " with milk";} print ".
"; if ($cake) {print "Sorry, we are out of $cake."} print "

Thank you for your visit. Please come again.


"; ---------------------------------------------------------------- 6) For the greeting card example, write a cgi script that prints "you have selected image ..." and the number of the image selected. Then the cgi script prints textboxes for the recipient's email address, the recipient's name and the message. #!/usr/local/bin/perl use CGI qw(:standard); print header(); print " Greeting Card

Your Card:

"; my $image = param("image"); print "You have selected image $image:"; print ""; print "

Recipient's email:
Recipient's name:
Message:


"; ---------------------------------------------------------------- 7) The greeting card example shows that parameters can be added to a URL (for example "greeting?image=3"). Try what happens if you enter parameter values other than 1, 2, 3 or 4. Add an if statement to your cgi script that prints "not an acceptable selection" if the image number is not 1, 2, 3 or 4. my $image = param("image"); if ($image != 1 and $image != 2 and $image != 3 and $image != 4) { print "not an acceptable selection"; die; } # 'die;' terminates the program. # In case of an unacceptable selection, there is no need to continue # with the program. print "You have selected image $image:";