Matt,
I have made the changes you sugested. I aplolgise ahead of time because this is going to be another long post.
Entire code looks like this:
#!/usr/bin/perl
use CGI;
use diagnostics;
# Create the CGI object
my $query = new CGI;
# Output the HTTP header
print $query->header ( );
sub process_form
{
if ( validate_form ( ) )
{
print<<END_HTML;
<html><head><title>Welcome to McHenry"s Soberfest Registration Confirmation Page</title></head>
<body>
<p class="next">Thanks for filling in our form!<br>
You will need to return to the form and fill it out for each registrant that you have paid for.<br>
This is so that we can match the PayPal receipt to your registration.<br>To Complete Registering Multiple Guests, <a href="../register/register.php">Click Here</a>.<br><br>
Your Registration will be processed immediately.<br> Your Conference Packet will be available, as always, at the Registration Table at the Conference.<br><br>
See you there!</p>
</body></html>
END_HTML
}
}
# Display the form
display_form( );
print<<END_HTML;
<html>
<title>Welcome to McHenry's Soberfest Online Registration Page</title>
<!---- Do Not Edit Above this Line ------>
<td valign="top"><!--- begin insert of content here --->
<p class="next">Welcome to the McHenry's Soberfest Online Registration form.<br>
Your transaction with PayPal has been completed sucsessfully! You should be receiving e-mail confirmation from PayPal shortly.<br>
You are only a few minutes away from being registered for the Conference.<br><br>
This form will be used by the Registration sub-committee to assign seating at the Banquet, assess and meet all Special Needs of our guests and update the Registration database for next year's Conference.<br><br>Please fill in all of the following fields.<br><br></p>
<p> $error_message </p>
<!--- begin registration form --->
<form action="Validation_Form.cgi" method="post">
Email Address:<br>
<input type="text" name="email" value=$email> <br>
First name: <br>
<input type="text" name="firstname" value=$firstname> <br>
Last name:<br>
<input type="text" name="lastname" value=$lastname><br>
Address: <br>
<input type="text" name="address" value=$address><br><br>
City:
<input type="text" name="city" value=$city>
State:
<input type="text" name="state" size="2" value=$state>
Zip Code:
<input type="text" name="zip" size="5" value=$zip><br><br>
Phone: <input type="text" name="phone" value=$phone>
Special Needs: <input type="text" name="specneeds" value=$specneeds><br><br>
<input type="radio" name="type" value="AA"> AA
<br>
<input type="radio" name="type" value="$AAunder"> AA (under 18 years of age)
<br>
<input type="radio" name="type" value="$Alanon"> AL-ANON
<br>
<input type="radio" name="type" value="$ATeen"> ALATEEN
<br>
<input type="radio" name="type" value="$Under8">Child under 8 years of age
<br><br>
Please select the number of registrations you paid for via PayPal before accessing this registration form.<br>
<select name="RegCount">
<option value="1">1 Registration</option>
<option value="2">2 Registrations</option>
<option value="3">3 Registrations</option>
<option value="4">4 Registrations</option>
<!...180...>
<option value="5">5 Registrations</option>
<option value="6">6 Registrations</option>
<option value="7">7 Registrations</option>
<option value="8">8 Registrations</option>
<option value="9">9 Registrations</option>
<option value="10">10 Registrations</option>
</select>
<br><br>
Last Name of Payor (if different than yours)<br>
<input type="text" name="payor" value=$payor> <br><br>
<p class="next">
Please remember, Persons under the age of 18 MUST be accompanied throughout the conference
by a parent or legal guardian.<br> Alateens must be 8 years old to register and attend meetings.</p>
<br>
<input type="submit" name="submit" value="Send">
<input type="reset" name="reset" value="Reset">
</form>
</html>
END_HTML
# Process form if submitted; otherwise display it
if ( $query->param("Send") )
{
process_form ( );
}
else
{
display_form ( );
}
sub display_form
{
$error_message = shift;
$email = shift;
$firstname = shift;
$lastname =shift;
$address = shift;
$city = shift;
$state = shift;
$phone = shift;
$specneeds = shift;
$payor = shift;
}
sub validate_form
{
# Capture the form results
$email = $query->param("email");
$firstname = $query->param("firstname");
$lastname = $query->param("lastname");
$address = $query->param("address");
$city = $query->param("city");
$state = $query->param("state");
$zip = $query->param("zip");
$phone = $query->param("phone");
$specneeds = $query->param("specneeds");
$AA = $query->param("AA");
$AAunder = $query->param("AAunder");
$Alanon = $query->param("Alanon");
$ATeen = $query->param("ATeen");
$Under8=$query->param("Under8");
$payor=$query->param("payor");
}
{
if ( $error_message )
# Errors with the form - redisplay it and return failure
{
display_form ($error_message, $email, $firstname, $lastname, $address,
$city, $state, $zip, $phone, $payor);
return (0);
}
else
# Form OK - return success
{
return (1);
}
}
my $error_message = "";
$error_message.="Please enter your email adress<br>" if (!$email);
$error_message.="Please enter your first name<br>" if (!$firstname);
$error_message.="Please enter your last name<br>" if (!$lastname );
$error_message.="Please enter your address<br>" if (!$address);
$error_message.="Please enter your city<br>" if (!$city);
$error_message.="Please enter your state<br>" if(!$state);
$error_message.="Please enter your zip code<br>"if (!$zip);
$error_message.="Please enter your phone number<br>" if (!$phone);
$error_message.="Please enter any Special Needs. If none, enter 'none'<br>" if (!$specneeds);
$error_message.="Please specify payor<br>" if (!$payor);
#Mail The Results
{
open ( MAIL,"| /usr/lib/sendmail -t" );
print MAIL "From: $email\n";
print MAIL "To: Cotechnical\@soberfest.org\n";
print MAIL "CC: Dougger57\@aol.com\n";
print MAIL "Subject: Form Submission\n\n";
print MAIL "$email\n";
print MAIL "$firstname\n";
print MAIL "$lastname\n";
print MAIL "$address\n";
print MAIL "$city\n";
print MAIL "$state\n";
print MAIL "$zip\n";
print MAIL "$phone\n";
print MAIL "$specneeds\n";
print MAIL "$AA\n";
print MAIL "$AAunder\n";
print MAIL "$Alanon\n";
print MAIL "$ATeen\n";
print MAIL "$Under8\n";
print MAIL "$payor\n";
print MAIL "\n.\n";
close ( MAIL );
}
#Filter the form results
{
$email = filter_header_field ($email);
$firstname = filter_field ($firstname);
$lastname = filter_field ($lastname );
$address = filter_field ($address);
$city = filter_field ($city);
$state = filter_field ($state);
$zip = filter_field ($zip);
$phone = filter_field ($phone);
$specneeds = filter_field ($specneeds);
$AA = filter_field ($AA);
$AAunder = filter_field ($AAunder);
$Alanon = filter_field ($Alanon);
$ATeen = filter_field($ATeen);
$Under8 = filter_field($Under8);
$payor = filter_field($payor);
}
# Functions for filtering user input
sub filter_field
{
my $field = shift;
$field =~ s/From://gi;
$field =~ s/To://gi;
$field =~ s/BCC://gi;
$field =~ s/CC://gi;
$field =~ s/Subject://gi;
$field =~ s/Content-Type://gi;
return $field;
}
sub filter_header_field
{
my $field = shift;
$field =~ s/From://gi;
$field =~ s/To://gi;
$field =~ s/BCC://gi;
$field =~ s/CC://gi;
$field =~ s/Subject://gi;
$field =~ s/Content-Type://gi;
$field =~ s/[\0\n\r\|\!\/\<\>\^\$\%\*\&]+/ /g;
return $field;
}
Error log looks like this:
Use of uninitialized value in concatenation (.) or string at
/home/content/s/f/t/sftechnical/html/register/Validation_Form.cgi line 38 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
To help you figure out what was undefined, perl tells you what operation
you used the undefined value in. Note, however, that perl optimizes your
program and the operation displayed in the warning may not necessarily
appear literally in your program. For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.
Can't return outside a subroutine at
/home/content/s/f/t/sftechnical/html/register/Validation_Form.cgi line 164 (#2)
(F) The return statement was executed in mainline code, that is, where
there was no subroutine call to return out of. See perlsub.
Uncaught exception from user code:
Can't return outside a subroutine at /home/content/s/f/t/sftechnical/html/register/Validation_Form.cgi line 164.
The form is displayed, but won't validate nor mail.
Once again, thank you in advance for your help!
Doug