#!/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 "CGI Demo Form Message"; print ""; unless ( ($in{FirstName} && $in{LastName} && $in{Telephone}) || ($in{FirstName} && $in{LastName} && $in{Email}) ) { # the user did not send us the minimum amount of information, # spit out an error print "There was a problem with the data you entered. In order for us to contact you ", "we need your first and last name and either your email address, or telephone number.

", "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.


", "
Comments, questions, or problems to ", "rivelli\@redshift.com

$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 "

Thanks for completing the CGI Demonstration Form!

"; print "

This is the data you entered:

"; 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 "

You can use your browser's BACK button to return to the CGI Demonstration Form or...

"; print "

", "

Click here to return to Tom Rivelli Associates Home Page

"; print "
Questions, comments, or problems to "; print "rivelli\@redshift.com"; print "

$date"; print "

"; exit(1);