Home
#!/usr/bin/perl -w #========================================================================= # Copyright 1999-2001 Idocs Guide to HTML, http://www.idocs.com/ # You may distribute this program freely, but keep # this notice in place. #========================================================================= #========================================================================= # modules # use strict; use CGI; use CGI::Carp 'fatalsToBrowser', 'croak'; # use lib 'pt/PtLib'; # use lib 'ads/'; # use Banner; # # modules #========================================================================= #========================================================================= # variables # my ( $query, # CGI query object $maxFields, # maximum number of fields to accept $rand, # random number for banners $inputdata, # filehandle for uploaded files @inputVals, # values for a field (they can send more than one) $inputVal, # a single values for a field $modval, # modified value of $fileinfo, # uploaded file information @params, # array of all fields sent $key,$val, # key an value for $fileinfo hash $ad,$adcode, ); $query=CGI->new; # get CGI object $maxFields=100; # maximum number of fields to accept $rand = int(rand(100000)); # random number for ad banner # # variables #========================================================================= #========================================================================= # top of page # print $query->header; print <<"(TOPOFPAGE)";![]() |
My CGI
This CGI displays thename=value
pairs sent to it. Feel
free to use this CGI for practice making HTML forms. This CGI is provided
compliments of the HTML Code Tutorial.(TOPOFPAGE) # # top of page #========================================================================= #========================================================================= # list # # get list of fields @params = $query->param; if (@params > $maxFields) {croak "No more than $maxFields fields please"} # open table if necessary print "
", tablesc($paramKey), " | ", "
| ', tablesc($paramKey), ' | '; #out put value(s) for field foreach $inputVal (@inputVals) {$inputVal = tablesc($inputVal)} print join(" | ||||||
---|---|---|---|---|---|---|---|---|---|
", @inputVals), ' | ';
}
#
# value
#----------------------------------------------------------------
print "
n" if @params; # # list #========================================================================= #======================================================================= # bottom of document # # ************************************************************************ # *** IF YOU COPY My CGI, ABSOLUTELY PLEASE DO NOT CHANGE THIS SECTION *** # ************************************************************************ print <<"(END BOTTOM OF PAGE)";
A lot of people have asked to see the code for this CGI. OK, here it is. (END BOTTOM OF PAGE) # # bottom of document #======================================================================= #======================================================================= # tablesc # return undefined or for space-only/empty string, # otherwise change < > and & to character entities # sub tablesc { return " " if (! defined $_[0]) || ($_[0] !~ m|S|); $_[0] =~ s|&|&|gso; $_[0] =~ s|<|<|gso; $_[0] =~ s|>|>|gso; $_[0]; } # # tablesc #=======================================================================