#!/usr/bin/perl -w push(@INC,"/www/cgi-bin"); require 5.003; require "cgi-lib.pl"; #-------------------------- What This Does ---------------------------- # If the Vote Form is missing data, indicate the error and return the # form with the same data they submitted. # # Changed: Preliminaries and VoteForm Deleted: missing #---------------------------- Configure ---------------------------- $data_dir = "/www/cgi-bin/210/vote"; # Directory where data is kept $voted = "$data_dir/voted"; # those who already voted $form = "http://hans.math.upenn.edu/cgi-bin/210/vote/vote7.pl"; # The next vote tally file will have only one line. That line has the # vote data contained in %tally shown in the "What this does" section above. $votefile = "$data_dir/Votes"; # The lists of candidates: @candidates = ("Bush","Gore","someone else","undecided"); #---------------------------- Main Program ---------------------------- &ReadParse; print &PrintHeader; &Preliminaries; # If there is no data (so the hidden field in the form is not defined), # only print the blank vote form. if (!defined($in{hidden})) { &VoteForm; exit; } # If something is missing, print an error message and return to form. if (($in{lastname} eq "") || ($in{firstname} eq "") || ($in{"pres"} eq "")) { $missing = "true"; &VoteForm; } else { # Their ballot is complete. OK unless voted already. &AlreadyVoted; if ( $alreadyvoted ne "yes") { &RecordVote; # Record vote, add name to voted list &Thanks; # Thanks and give current tally. &ClosePage; } } # end Main Program #--------------------------------------------------------------- sub Preliminaries { # Next is a useful "Return to the Form" button. $header = '
| Return to Voting Forms Page |
";
}
print <
$err
Return to Voting Forms
Page
An Election Poll