#!/usr/bin/perl -- -*- C -*- # CGI Demo Form # 05/11/96 - rivelli@redshift.com # called by http://redshift.com/~trivelli/demo/cgi-eg.html # # 1.0 - collects data from the user's submitted demonstration form, # parses it and translates where necessary into an intelligible format. # Then writes the whole thing to the data file for future use; also sends back # the submitted data for the user to see as a demonstration. Notifies # rivelli@redshift.com by email of SUCCESSFUL or FAILED submittal using # the sendmail daemon on the server. # # 1.1 - error handling added # require "formlib.pl"; $| = 1; # output NOT buffered chop ($date = `/bin/date`); # for the 'this page created' line at the bottom &GetPostArgs(); # parse arguments passed from FORM (now in %in) $ENV{PATH_INFO} ne '' && &GetPathArgs($ENV{PATH_INFO}); print "Content-type: text/html\n\n"; ############################################################################ print "
", "If you wish to correct your data, ", "use the BACK button now on your browser to retain ", "your entries and return to the CGI Demonstration Form.
$date
"; # Print the deficient data to the file anyway for review # while (-e "cgiinfo.LCK") { # system ("sleep 3"); # } open (LOCK, ">> cgiinfo.LCK"); open (CGIINFO, ">> cgiinfo"); print CGIINFO "\n====================SUBMISSION FAILED=== $date\n"; print CGIINFO "FirstName: $in{FirstName}\n"; print CGIINFO "Last Name: $in{LastName}\n"; print CGIINFO "Telephone: $in{Telephone}\n"; print CGIINFO "Email: $in{Email}\n"; print CGIINFO "How Heard of Tom Rivelli Associates:\n $in{HowHeard}\n"; print CGIINFO "Computer Hours: $in{ComputerHours}\n"; print CGIINFO "Computer Minutes: $in{ComputerMinutes}\n"; print CGIINFO "Daily/Weekly/Monthly: $in{ComputerInterval}\n"; close (CGIINFO); unlink ("cgiinfo.LCK"); # notify trivelli of the form submission FAILED by email open (MESSAGE, "| /usr/bin/sendmail rivelli\@redshift.com"); print MESSAGE "To: rivelli\@redshift.com\n"; print MESSAGE "Subject: Submission from CGI DEMO FAILED\n"; print MESSAGE "Date: $date\n"; close (MESSAGE); exit (1); # end the CGI right here. } # we now continue with our regularly scheduled CGI # while (-e "cgiinfo.LCK") { # system ("sleep 3"); # } open (LOCK, ">> cgiinfo.LCK"); open (CGIINFO, ">> cgiinfo"); print CGIINFO "\n======================================= $date\n"; print CGIINFO "FirstName: $in{FirstName}\n"; print CGIINFO "Last Name: $in{LastName}\n"; print CGIINFO "Telephone: $in{Telephone}\n"; print CGIINFO "Email: $in{Email}\n"; print CGIINFO "How Heard of Tom Rivelli Associates:\n $in{HowHeard}\n"; print CGIINFO "Computer Hours: $in{ComputerHours}\n"; print CGIINFO "Computer Minutes: $in{ComputerMinutes}\n"; print CGIINFO "Daily/Weekly/Monthly: $in{ComputerInterval}\n"; close (CGIINFO); unlink ("cgiinfo.LCK"); # notify trivelli of the form submission SUCCESSFUL by email open (MESSAGE, "| /usr/bin/sendmail rivelli\@redshift.com"); print MESSAGE "To: rivelli\@redshift.com\n"; print MESSAGE "Subject: Submission from CGI DEMO SUCCESSFUL\n"; print MESSAGE "Date: $date\n"; close (MESSAGE); # send the data back to the user on an html page. print "==============================================
"; print "First Name: $in{FirstName}
"; print "Last Name: $in{LastName}
"; print "Telephone: $in{Telephone}
"; print "Email: $in{Email}
"; print "How Heard of Tom Rivelli Associates:$in{HowHeard}
"; print "Computer Hours: $in{ComputerHours}
"; print "Computer Minutes: $in{ComputerMinutes}
"; print "Daily/Weekly/Monthly: $in{ComputerInterval}
"; print "==============================================
"; print "$date"; print "
"; exit(1);