If you want to check if it is empty, Here is a suggestion.
PHP Code:
if($act =="")
{
switch($_GET['act'])
{
default:
// Put the Form Code Here - Have the form's "Action" direct to something like form.php?act=check
break;
case"check":
$name = $_POST["name"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$comments = $_POST["comments"];
// Empty Feilds
if(empty($email)){
Echo"Your email address is required. Click <a href=''>here</a> to go back.";
exit;
}
$today = date("M d, Y");
$recipient = "buyersreport@sanjoserealty.net";
$subject = "Free Buyers Report Request";
$forminfo =
"Name: $name\n
Phone: $phone\n
Email: $email\n
Comments: $comments\n
Form Submitted: $today\n\n";
$formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email");
break;
}
}
?>
<!-- The rest of the site-->
Please note: Once the text is outputted that the email address is empty, it will "Kill" the code from so on. So please note that if you want to do more "Checks" and do not want to kill it yet, do something else.
But, using the case's and switches allow you to break away without exiting etc.
Also - Remember, the form actions "?act=" has to be the case as the case"": or it will not work. Some smarter person will probably come in here and say i'm wrong, but thats okay lol
Bookmarks