Fall Semester 2007
Each part has two parts: a warm-up and an exercise. We'll work them out both in class.
Part One (Tuesday lecture).
partOne and place it in your
Call the form
partOne.html and put it in
Make the form submit the data to the program
partOne in your
partOne(the program) to also print
Use the form to send some data to the program. What do you notice?
Call the program
counter and place it in
cgi-bin next to the other program.
balanceis noticed on the URL make the program report it.
So if the URL is
counter?balance=6 the program should report the balance (as an
<h1>) then the link as before.
How does the program work now? What does it do?
#!/usr/bin/perl use CGI; # import the CGI.pm module (library) $q = new CGI; # data binding: create object $q that parses and stores incoming data print $q->header, $q->start_html; # instance methods header and start_html produce strings for corresponding HTML sections print $q->param('balance'); # the value associated with balance (if any) is extracted, and printed print $q->end_html; # print the string for the end of HTML document, produced by instance method end_html
Try rewriting one of the two programs discussed above (e.g.,
counter) using this
Part Two (Thursday lecture).
portfolio) that prints four links and a picture.
Put the program in
cgi-bin, make it executable,
test it. Here's the model.
Have the program report what's being asked (the param and the value or, at the very least, the query string).
Play with this script to clarify what that means if it's unclear.
counterprogram from Part One using one textfield and one submit button only (no embedded links).
Hint: textfield's name is
balance so you can store your state there.
(Ugly, perhaps, but functional. What if the textfield becomes a hidden field?)
calculatorby adding textfields in the interface to indicate