Code: Select all
<html>
<body>
<?php
function check_field1($newVariableName)
{
if(preg_match("/[^A-Z]+$/s",$newVariableName))
{
return TRUE;
}
else
return FALSE;
}
if ($_POST)
[color=#FF0000]{ $Franlist = $_POST["ranlist"];
$Fcopy = $_POST["copy"];
if ($Franlist <> $Fcopy)
echo "You did not COPY the number correctly. Please try again";
}
else[/color]
{
$Fname = $_POST["username"];
$Fmail = $_POST["usermail"];
$FAddress1 = $_POST["Address1"];
$FAddress2 = $_POST["Address2"];
$FCity = $_POST["City"];
$FState = $_POST["State"];
$FZip = $_POST["Zip"];
$FPhone = $_POST["Phone"];
$FSite = $_POST["site"];
$FComment = $_POST["comment"];
$to = "samc@xxxxxx.com";
$subject = "Guest Book Entry";
$from = $_POST["usermail"];
$headers = "From: $from";
$message ="\r\n Username: " . $Fname . "\r\n Usermail: " . $Fmail . "\r\n Address1: " . $FAddress1 . "\r\n Address2: " . $FAddress2 . "\r\n City: " . $FCity . "\r\n State: " . $FState . "\r\n Zip: " . $FZip . "\r\n Phone: " . $FPhone . "\r\n Site: " . $FSite . "\r\n Comments: " . $FComment;
}
[color=#0000FF]if(!check_field1($Fname))
{
echo "NAME is REQUIRED";[/color]
[color=#FF0000]echo '<p />';
echo '<center>';
echo '<a href="TestGuestBook.html">Return to Guest Book</a>';
echo '   ';[/color]
echo '<a href="Index.shtml">HOME</a>';
echo '</center>';
}
else
{
// If there are no errors then
if (mail($to,$subject,$message,$headers))
{
echo '<p>The Guest Book was updated. Thank You.</p>';
echo '<center>';
echo '<a href="Index.shtml">HOME</a>';
echo '</center>';
}
}
?>
</body>
</html>I added the code you see highlighted in "red" above.
My problem: The routine is always failing the Name check (highlighted in BLUE) On the form, even though I enter a NAME, I am getting the message "Name is Required".
I can't find the error. Can You Help????
Thanks, Sam