#! /usr/local/bin/perl # Order Form Generation Lab: Student version # # Begin loading the needed extensions # use DBI; # The DBI extension use CGI qw (:html2 :form); # The CGI extension use CGI::Carp qw (carpout); # The extra carping routine # # The file dbtype.pl sets a variable which determines the type of database # you will use. This file will be found in either /tmp or /temp. # use lib qw(/tmp /temp); require 'dbtype.pl'; # # Set the path, unbuffer STDOUT, and redirect errors to the browser # $ENV{PATH} = join ":", qw(/usr/bin /bin /sbin /usr/sbin /etc); $| = 1; carpout(\*STDOUT); # # Declare variables # my( $dbh, $rv, $sth ); my( $tid, $name, $price, $edition ); my( @sequence, %labels ); ### # # STUDENT: Comment these out when you load your order form from the Nile DB # # @sequence contains the actual value that will be passed to the CGI script # that will process this form # # %labels maps the value from @sequence to the actual string that the user # will see in their browser # @sequence = qw( 1 2 3 ); %labels = ( "1" => "The Idiot's Guide to Chewing (9.99)", "2" => "Breathing for Dummies (34.99)", "3" => "Walking Made Simple (67.99)", ); # # Accept the CGI request # my( $q ) = new CGI; # # Send the HTTP header # print $q->header; # # Set the
| Name: "; print " | ", textfield( -name => "cust_name", -size => 40, -maxlength => 80, ); print " |
| Address: "; print " | ", textfield( -name => "cust_address", -size => 40, -maxlength => 80, ); print " |
| Credit Card: "; print " | ", radio_group( -name => 'card_type', '-values' => ['Visa', 'MasterCard', 'Discover', 'Other'], -linebreak => 'true', ); print " |
| Card Number: "; print " | ", textfield( -name => "card_number", -size => 20, -maxlength => 30, ); print " |
| Copies: "; print textfield( -name => "num_copies", -size => 2, -maxlength => 3, ); print " | "; print scrolling_list( -name => 'title_list', '-values' => \@sequence, -size => 10, -labels => \%labels); print " |