roadrunnerray
12-10-2007, 06:26 PM
I created a Pearl script about 3-years ago and have not done anything with Pearl since then. My usually foggy mind is more so after this extended period.
I recently modified this script and am having a problem.
The Pearl script executes OK but the data I print to the browser is not correct.
The data printed to browser is displayed below (note the Name prints correctly but the Title field appears to print the *key* [title for the second field right after the data for the 1st field]). The remaining form fields do not print….
---------------------------------------------------------------------------------------
Name: John Doe title
Title:
Email Address:
Daytime Telephone:
Affiliation:
I Will Attend:
Lodging:
Dinner:
Special Food Requirements:
---------------------------------------------------------------------------------------
Here is the HTML Form:
---------------------------------------------------------------------------------------
<form action="http://128.123.83.183/cgi-bin/ADVANCERegForm.pl" method="post" enctype="text/plain">
<p><strong> Name (First/Last)</strong><br />
<input type="text" class="formField" name="fullname" size="60"></input></p>
<p><strong>Title</strong><br />
<input type="text" class="formField" name="title" size="60"></input></p>
<p><strong>Email Address</strong><br />
<input type="text" class="formField" name="email" size="60"></input></p>
<p><strong>Daytime Telephone (With Area Code)</strong><br />
<input type="text" class="formField" name="phone" size="60"></input></p>
<p><strong>Affiliation:</strong>
<select name="affiliation">
<option selected="selected">LANL</option>
<option>NMSU</option>
<option>NMT</option>
<option>UNM</option>
</select></p>
<p><strong>I will attend:</strong><br />
<input type="radio" name="day" value="Wednesday"></input>Wednesday only<br />
<input type="radio" name="day" value="Thursday"></input>Thursday only<br />
<input type="radio" checked="checked" name="day" value="Both"></input>Wednesday and Thursday</p>
<p><strong>Lodging</strong><br />
<input type="radio" name="lodging" value="Elephant Butte Inn" checked="checked" ></input>
I will lodge overnight at Elephant Butte Inn<br />
<input type="radio" name="lodging" value="Own Arrangements" ></input>I will make my own lodging arrangements.</p>
<p><strong>I will have dinner Wednesday night at Elephant Butte Inn:</strong><br />
<input type="radio" name="dinner" value="Yes" checked="checked" ></input>Yes<br />
<input type="radio" name="dinner" value="No" ></input>No</p>
<p><strong>Please indicate any special food requirements</strong><br />
(vegetarian, wheat or dairy allergies, etc.):<br />
<textarea name="special" rows="5" cols="60"></textarea></p>
<p><input type="submit" value="Register"></input>
<input type="reset" value="Reset"></input></p>
</form>
--------------------------------------------------------------------------------------
Here is the Pearl script:
--------------------------------------------------------------------------------------
$mailprog = '/usr/sbin/sendmail';
# ==================================================================================================
# Email address of the ADVANCE department being notified of registration (paid@advance.nmsu.edu)
# ==================================================================================================
$recipient = 'rleseth@nmsu.edu';
# ==================================================================================================
# Print out a content-type for HTTP/1.0 compatibility
# ==================================================================================================
print "Content-type: text/html\n\n";
# ==================================================================================================
# Get the input from the submitted form
# ==================================================================================================
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# ==================================================================================================
# Split the name-value pairs
# ==================================================================================================
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# ==================================================================================================
# Un-Webify plus signs and %-encoding
# ==================================================================================================
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$Value =~ s/<!--( . | \n) *-->//g;
# Stop people from using subshells to execute commands
# Not a big deal when using sendmail, but very important
# when using UCB mail (aka mailx).
# $value =~ s/~!/ ~!/g;
# Uncomment for debugging purposes
# print "Setting $name to $value<P>";
$FORM{$name} = $value;
}
print MAIL "---------------------------------------------------------\n";
print MAIL "*************** Dept Head Retreat Registration ****************\n";
print MAIL "---------------------------------------------------------\n\n";
# =================================================================================================
# Demographic data on registrant emailed to ADVANCE (paid@nmsu.edu)
# =================================================================================================
print MAIL "---------------------------------------------------------\n";
print MAIL "Name: $FORM{'fullname'}\n";
print MAIL "Title: $FORM{'title'}\n";
print MAIL "Email: $FORM{'email'}\n";
print MAIL "Phone: $FORM{'phone'}\n";
print MAIL "Affiliation: $FORM{'affiliation'}\n";
print MAIL "Lodging: $FORM{'day'}\n";
print MAIL "Dinner: $FORM{'dinner'}\n";
print MAIL "Special Food: $FORM{'special'}\n";
print MAIL "---------------------------------------------------------\n\n";
close (MAIL);
# =================================================================================================
# Send confirmation of events selected to registrant via their web page
# =================================================================================================
# =================================================================================================
# Print title and initial heading to registrants web browser
# =================================================================================================
print "<Body background=\"/images/background.gif\"><H2>ADVANCE Event Registration Confirmation</H2><hr><p>";
print "<B>Thank you</B> for your registration.<BR><BR>";
print "<B>---------------------------------------------------------------------------------------</B><BR>";
# =================================================================================================
# Print all selected events to registrants web browser
# =================================================================================================
print "<B>---------------------------------------------------------------------------------------</B><BR>";
# =================================================================================================
# Print registrants demographic data to their web browser
# =================================================================================================
print "Name: $FORM{'fullname'}<BR>";
print "Title: $FORM{'title'}<BR>";
print "Email Address: $FORM{'email'}<BR>";
print "Daytime Telephone: $FORM{'phone'}<BR>";
print "Affiliation: $FORM{'affiliation'}<BR>";
print "I Will Attend: $FORM{'day'}<BR>";
print "Lodging: $FORM{'lodging'}<BR>";
print "Dinner: $FORM{'dinner'}<BR>";
print "Special Food Requirements: $FORM{'special'}<P><P>";
print "<B>---------------------------------------------------------------------------------------</B><BR>";
# =================================================================================================
# Print request asking registrant to print their confirmation page and provide link back to event page
# =================================================================================================
print "Please <B>print a copy</B> of this confirmation for your records.<BR>";
print "<B>---------------------------------------------------------------------------------------</B><BR>";
print "<BR>Return to the <A HREF=\"http://www.advance.nmsu.edu\">ADVANCE Home Page</A>.<P>";
# =================================================================================================
# Subroutine (blank_response) to notify registrant that they have excluded required fields
# =================================================================================================
sub blank_response
{
print "<H2><font color=red>Error!</font> - A required field was left blank!</H2><P>";
print "Please enter information for all <B>required</B> fields on the registration form.<P>";
print "Call xxxx at xxx-xxxx if you need assistance.<P>";
print "Thank You,<P>";
print "Return to the <A HREF=\"http://www.advance.nmsu.edu/PAID/Documents/Retreat08_RegForm.html\">Registration Form</A>.<P>";
exit;
}
-------------------------------------------------------------------------------------
Any assistance will be greatly appreciated............Ray
I recently modified this script and am having a problem.
The Pearl script executes OK but the data I print to the browser is not correct.
The data printed to browser is displayed below (note the Name prints correctly but the Title field appears to print the *key* [title for the second field right after the data for the 1st field]). The remaining form fields do not print….
---------------------------------------------------------------------------------------
Name: John Doe title
Title:
Email Address:
Daytime Telephone:
Affiliation:
I Will Attend:
Lodging:
Dinner:
Special Food Requirements:
---------------------------------------------------------------------------------------
Here is the HTML Form:
---------------------------------------------------------------------------------------
<form action="http://128.123.83.183/cgi-bin/ADVANCERegForm.pl" method="post" enctype="text/plain">
<p><strong> Name (First/Last)</strong><br />
<input type="text" class="formField" name="fullname" size="60"></input></p>
<p><strong>Title</strong><br />
<input type="text" class="formField" name="title" size="60"></input></p>
<p><strong>Email Address</strong><br />
<input type="text" class="formField" name="email" size="60"></input></p>
<p><strong>Daytime Telephone (With Area Code)</strong><br />
<input type="text" class="formField" name="phone" size="60"></input></p>
<p><strong>Affiliation:</strong>
<select name="affiliation">
<option selected="selected">LANL</option>
<option>NMSU</option>
<option>NMT</option>
<option>UNM</option>
</select></p>
<p><strong>I will attend:</strong><br />
<input type="radio" name="day" value="Wednesday"></input>Wednesday only<br />
<input type="radio" name="day" value="Thursday"></input>Thursday only<br />
<input type="radio" checked="checked" name="day" value="Both"></input>Wednesday and Thursday</p>
<p><strong>Lodging</strong><br />
<input type="radio" name="lodging" value="Elephant Butte Inn" checked="checked" ></input>
I will lodge overnight at Elephant Butte Inn<br />
<input type="radio" name="lodging" value="Own Arrangements" ></input>I will make my own lodging arrangements.</p>
<p><strong>I will have dinner Wednesday night at Elephant Butte Inn:</strong><br />
<input type="radio" name="dinner" value="Yes" checked="checked" ></input>Yes<br />
<input type="radio" name="dinner" value="No" ></input>No</p>
<p><strong>Please indicate any special food requirements</strong><br />
(vegetarian, wheat or dairy allergies, etc.):<br />
<textarea name="special" rows="5" cols="60"></textarea></p>
<p><input type="submit" value="Register"></input>
<input type="reset" value="Reset"></input></p>
</form>
--------------------------------------------------------------------------------------
Here is the Pearl script:
--------------------------------------------------------------------------------------
$mailprog = '/usr/sbin/sendmail';
# ==================================================================================================
# Email address of the ADVANCE department being notified of registration (paid@advance.nmsu.edu)
# ==================================================================================================
$recipient = 'rleseth@nmsu.edu';
# ==================================================================================================
# Print out a content-type for HTTP/1.0 compatibility
# ==================================================================================================
print "Content-type: text/html\n\n";
# ==================================================================================================
# Get the input from the submitted form
# ==================================================================================================
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# ==================================================================================================
# Split the name-value pairs
# ==================================================================================================
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# ==================================================================================================
# Un-Webify plus signs and %-encoding
# ==================================================================================================
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$Value =~ s/<!--( . | \n) *-->//g;
# Stop people from using subshells to execute commands
# Not a big deal when using sendmail, but very important
# when using UCB mail (aka mailx).
# $value =~ s/~!/ ~!/g;
# Uncomment for debugging purposes
# print "Setting $name to $value<P>";
$FORM{$name} = $value;
}
print MAIL "---------------------------------------------------------\n";
print MAIL "*************** Dept Head Retreat Registration ****************\n";
print MAIL "---------------------------------------------------------\n\n";
# =================================================================================================
# Demographic data on registrant emailed to ADVANCE (paid@nmsu.edu)
# =================================================================================================
print MAIL "---------------------------------------------------------\n";
print MAIL "Name: $FORM{'fullname'}\n";
print MAIL "Title: $FORM{'title'}\n";
print MAIL "Email: $FORM{'email'}\n";
print MAIL "Phone: $FORM{'phone'}\n";
print MAIL "Affiliation: $FORM{'affiliation'}\n";
print MAIL "Lodging: $FORM{'day'}\n";
print MAIL "Dinner: $FORM{'dinner'}\n";
print MAIL "Special Food: $FORM{'special'}\n";
print MAIL "---------------------------------------------------------\n\n";
close (MAIL);
# =================================================================================================
# Send confirmation of events selected to registrant via their web page
# =================================================================================================
# =================================================================================================
# Print title and initial heading to registrants web browser
# =================================================================================================
print "<Body background=\"/images/background.gif\"><H2>ADVANCE Event Registration Confirmation</H2><hr><p>";
print "<B>Thank you</B> for your registration.<BR><BR>";
print "<B>---------------------------------------------------------------------------------------</B><BR>";
# =================================================================================================
# Print all selected events to registrants web browser
# =================================================================================================
print "<B>---------------------------------------------------------------------------------------</B><BR>";
# =================================================================================================
# Print registrants demographic data to their web browser
# =================================================================================================
print "Name: $FORM{'fullname'}<BR>";
print "Title: $FORM{'title'}<BR>";
print "Email Address: $FORM{'email'}<BR>";
print "Daytime Telephone: $FORM{'phone'}<BR>";
print "Affiliation: $FORM{'affiliation'}<BR>";
print "I Will Attend: $FORM{'day'}<BR>";
print "Lodging: $FORM{'lodging'}<BR>";
print "Dinner: $FORM{'dinner'}<BR>";
print "Special Food Requirements: $FORM{'special'}<P><P>";
print "<B>---------------------------------------------------------------------------------------</B><BR>";
# =================================================================================================
# Print request asking registrant to print their confirmation page and provide link back to event page
# =================================================================================================
print "Please <B>print a copy</B> of this confirmation for your records.<BR>";
print "<B>---------------------------------------------------------------------------------------</B><BR>";
print "<BR>Return to the <A HREF=\"http://www.advance.nmsu.edu\">ADVANCE Home Page</A>.<P>";
# =================================================================================================
# Subroutine (blank_response) to notify registrant that they have excluded required fields
# =================================================================================================
sub blank_response
{
print "<H2><font color=red>Error!</font> - A required field was left blank!</H2><P>";
print "Please enter information for all <B>required</B> fields on the registration form.<P>";
print "Call xxxx at xxx-xxxx if you need assistance.<P>";
print "Thank You,<P>";
print "Return to the <A HREF=\"http://www.advance.nmsu.edu/PAID/Documents/Retreat08_RegForm.html\">Registration Form</A>.<P>";
exit;
}
-------------------------------------------------------------------------------------
Any assistance will be greatly appreciated............Ray