I'm a student and very new to Perl and could use some help on why this isn't executing properly. Even when the criteria entered in is proper it will display all the error messages. I wanted it to display the errors that apply if need be or to display the thank you message if it all fields meet the proper criteria.
#!/usr/bin/perl
print "Content-type: text/html\n\n";
use CGI qw(:standard);
$rn = param("Reservation Name");
$rc = param("Reservation Create Date");
$rr = param("Reservation Room Type");
$rnd = param("Reservation Number of Days");
$rs = param("Reservation Start Date");
$re = param("Reservation Room Cost");
$rp = param("Reservation Payment Method");
$rd = param("Reservation Discount Code");
$e1 = 0;
$e2 = 0;
$e3 = 0;
$e4 = 0;
$e5 = 0;
$e6 = 0;
$e7 = 0;
$e8 = 0;
$errors = 0;
if ( $rn eq "")
{
$e1 = 1;
$errors =1;
}
if ( $rc eq "")
{
$e2 = 1;
$errors = 1;
}
if ($rr ne "s" && $rr ne "d" && $rr ne "k" && $rr ne "m")
{
$e3 = 1;
$errors = 1;
}
if ( $rnd eq 0 || ($rnd gt 7 ))
{
$e4 = 1;
$errors = 1;
}
if ( $rs eq "")
{
$e5 = 1;
$errors = 1;
}
if ( $re le 65.00 || ($re gt 490.00))
{
$e6 = 1;
$errors = 1;
}
if ( $rp le 1 || ($rp gt 4 ))
{
$e7 = 1;
$errors = 1;
}
if ($rd le 5 || $rd gt 99)
{
$e8 = 1;
$errors = 1;
}
if ( $errors == 0 )
{
print "<html><body>Thank you for making your reservation</body></html>";
}
else
{
if ($e1 == 1)
{
print "<br>Reservation Number May Not Be Blank<br>";
}
if ($e2 == 1)
{
print "<br>Reservation Create Date may not be blank<br>";
}
if ($e3 == 1)
{
print "<br>The Room Type Must be leters S,D,K,or M<br>";
}
if ($e4 == 1)
{
print "<br>The number of days must be greate than zero and less than 7<br>";
}
if ($e5 == 1)
{
print "<br>The Start Date Must Not be Blank<br>";
}
if ($e6 == 1)
{
print "<br>The Room cost must be between $65.00 and $490.00<br>";
}
if ($e7 == 1)
{
print "<br>The payment method must be 1 thru 4<br>";
}
if ($e8 == 1)
{
print "<br>The discount code must be two digits and be on of the following
numbers 5,10,17,20<br>";
}
}
use strict;anduse warnings;in all your programs. They help you to spot syntax errors and other problems early on. You should also indent your code properly. It currently is pretty hard to read. You can edit your question and update the code. Also include the error messages that you are seeing, so we know what the problem is. You might also want to tell us what input you are using, as that is not obvious from the code, as well as an explanation of what your code is supposed to do. Also see minimal reproducible example.leorgtwith numbers.