1 #! /usr/npac/bin/perl -w 2 3 ############################################################################# 4 # 5 # File: fill-out-form.pl 6 # 7 # Input: fill-out-form0.html 8 # (variables address, phone, topping) 9 # 10 # Output: CGI.pm version of pizza order form 11 # 12 # Description: Creates a pizza order from the information obtained from 13 # the pizza order form. 14 # 15 # 16 ############################################################################# 17 # 18 # Initialization 19 # 20 ############################################################################# 21 22 $HTMLFILE = 'fill-out-form0.html'; # HTML doc with form 23 $HOSTPATH = 'http://www.npac.syr.edu/projects/tutorials/CGI/examples/basic-cgi'; 24 25 ############################################################################# 26 # 27 # Modules 28 # 29 ############################################################################# 30 31 use CGI qw(:standard); 32 33 ############################################################################# 34 # 35 # Main Routines 36 # 37 ############################################################################# 38 39 ReadEntry() && 40 PrintResult(); 41 42 ############################################################################## 43 # 44 # Input 45 # 46 ############################################################################## 47 48 sub ReadEntry { 49 $ADDRESS = param('address'); 50 $PHONE = param('phone'); 51 $TOPPING = param('topping'); 52 return 1; 53 } 54 55 ############################################################################# 56 # 57 # Output 58 # 59 ############################################################################# 60 61 sub PrintResult { 62 63 # Print MIME header: 64 print header(-type=>'text/html'); 65 66 # Print first few lines of the HTML document: 67 print start_html( 68 -title=>'CGI Example: Pizza', 69 -BGCOLOR=>'#ffffff' 70 ), "\n"; 71 72 # Print some headings: 73 print h1( 'Pizza Order' ), "\n"; 74 print h3( "$TOPPING pizza" ), "\n"; 75 76 # Print some paragraphs: 77 print p( "Deliver to: <B>$ADDRESS</B>" ), "\n"; 78 print p( "Telephone: <B>$PHONE</B>" ), "\n"; 79 $date = `date`; chomp($date); 80 print p( "Order came in at $date" ), "\n"; 81 82 # Print a horizontal rule: 83 print hr(); 84 85 # Print a link: 86 print 'Return to '; 87 print a({HREF=>"$HOSTPATH/$HTMLFILE"}, 88 'HTML form' 89 ), "\n"; 90 91 # Print last few lines of HTML document: 92 print end_html(), "\n"; 93 94 }