Basic HTML version of Foils prepared Sept 20 97

Foil 79 Using CGI.pm - Form Processing

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


1 Here's an example how to use CGI.pm to process form data:
2 print header(-type=>'text/html'); # MIME header
3 print start_html( # first few lines of HTML
  • -title=>'Pizza Order Form',
  • -BGCOLOR=>'#ffffff'
  • );
4 print h1( 'Pizza Order' );
5 print h3( "$TOPPING pizza" ); # $TOPPING = param(topping);
6 print p( "Deliver to: <B>$ADDR</B>" ); # $ADDR = param(address);
7 print p( "Telephone: <B>$PHONE</B>" ); # $PHONE = param(phone);
8 my $date = `date`; chomp($date);
9 print p( "Order came in at $date" );
10 print hr();
11 # Print a link:
12 print 'Return to ';
13 print a({href=>"fill-out-form.pl"}, # an anonymous hash
  • 'HTML form'
  • );
14 print end_html(); # last few lines of HTML

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Sep 21 1997