I am trying to put a required field for the $children field into an email reservation form. However if I enter 0 in this field I get an error message, any other number or text is fine, but if the guests don't have kids, I don't want to show an error. How do I get the PHP script to accept 0 as a valid answer? Help will be much appreciated.
Here is the script:
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$adults = $_POST['adults'];
$children = $_POST['children'];
$age = $_POST['age'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Please use browser Back button - Enter valid e-mail</h2>\n";
$badinput = "<h2>Your email was NOT submitted</h2>\n";
echo $badinput;
die ();
}
if(empty($visitor) || empty($visitormail) || empty($adults) || empty($children) || empty($notes )) {
echo "<h2>Please use browser Back button - Fill in all fields</h2>\n";
die ();
}
$todayis = date("l, F j, Y, g:i a") ;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Phone: $phone \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Referral : $httpref \n
";
$from = "From: $visitormail\r\n";
mail("me@atmysite.com", $subject, $message, $from);
?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank you <?php echo $visitor ?> for your message, we will contact you shortly.
<br />
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>