$tony="ascalder\@ce.ecn.purdue.edu";
# Adapted from Marc Clough's Perl Script
#Check that POST method is used
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
# POST method dictates that we get the form
# input from standard input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
#Split the Name-Value pairs on '&'
@data = split(/&/, $buffer);
# Go thought the pairs and determine the name
# and value for each form variable.
foreach $data (@data) {
($name, $value) = split(/=/, $data);
$value =~ tr/+/ /;
$value =~ /^[0-9\.]*[0-9\.]*[0-9]*[0-9]/;
$FORM{$name} = $value;
}
# Now all the form variable are in the $FORM
# associative array.
# Before proceeding, make sure that the input is valid.
# That is, all inputs must be numbers in ft/s.
# If input valid, proceed; If input illegal, write error message and
# force the user to reinput the data.
if ($FORM{velocity} !~ /^[0-9\.]*[0-9\.]*[0-9]*[0-9]/) {
&html_header("Invalid Velocity");
print "
\n";
print "The velocity input is not valid\. Make sure you have entered
a number from 0-10 ft/s\. This server only accepts values
in ft/s";
print "Please backup, correct, then resubmit your values\. \n";
&html_trailer;
exit;
}
if ($FORM{shear} !~ /^[0-9\.]*[0-9\.]*[0-9]*[0-9]/) {
&html_header("Invalid Shear");
print "
\n";
print "The shear input is not valid\. Make sure you have entered
a number from 0-7 psf\. (This server only accepts values
in ft/s)";
print "Please backup, correct, then resubmit your values\. \n";
&html_trailer;
exit;
}
if ($FORM{duration} !~ /^[temporary]|[permanant]/) {
&html_header("Invalid Shear");
print "
\n";
print "The radio button input is not valid. Make sure you have clicked
either the temporary or permanant buttons.";
print "Please backup, correct, then resubmit your values. \n";
&html_trailer;
exit;
}
# The users inputs are valid. So send the user to the appropriate URL
# Use an "if" statement to send the user to the correct products.
if ($FORM{velocity} <= 7.0 && $FORM{shear} <= 2.0 && $FORM{duration}
eq "temporary") { \n"; \n";
# open the file to be read & check that it is readable
open (low_velocity, "low_velocity.whtml");
if (open(low_velocity, "low_velocity.whtml")) {
$line =
}
else {
print "An error has occurred opening the file";
}
}
elsif ($FORM{velocity} <= 13.0 &&
$FORM{shear} <= 5.0 &&
$FORM{duration} eq "permanant") {
# open the file to be read & check that it is readable
open (perm, "perm.whtml");
if (open(perm, "perm.whtml")) {
$line =
}
else {
print "An error has occurred opening the file";
}
}
elsif ($FORM{velocity} > 7.0 || $FORM{shear} > 2.0 &&
$FORM{duration} eq "temporary") {
# open the file to be read & check that it is readable
open (perm, "perm.whtml");
if (open(perm, "perm.whtml")) {
$line =
}
else {
print "An error has occurred opening the file";
}
# &html_header("Error");
# print"
# print" Your inputs require";
";
# print" PERMs
# &html_trailer;
}
else {
&html_header("Error");
print"
print" Your inputs are too large for current erosion control products. \n";
\n";
print "Please go back to the inputs page and change your values!
print" PERMs
";
&html_trailer;
}
} #close the if loop from the start of the program
# if all goes bad, print the following message
else {
print "Uhh...Houston we've got a problem.....";
}