I've got a contact form that I would like to add email validation to. I would like to add the code shown HERE but don't know where it should be inserted in the page. The code I have so far is
Code:
<?
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
$_POST['firstname']=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $_POST['firstname']);if($_POST['firstname']=="" || $_POST['lastname']=="" || $_POST['email']=="" || $_POST['comments']=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($errors==1) $msg.="You did not enter one or more of the required fields.<br />Please go back and re-enter your contact request.";
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$_SERVER['HTTP_HOST'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
$message="
Firstname: ".$_POST['firstname']."
Lastname: ".$_POST['lastname']."
Email: ".$_POST['email']."
Address: ".$_POST['address']."
City: ".$_POST['city']."
State: ".$_POST['state']."
Zip: ".$_POST['zip']."
Phone: ".$_POST['phone']."
Interested: ".$_POST['interested']."
Comments: ".$_POST['comments']."
";
mail("someone@somewhere.com","Stuff",$message,"From: Web Form");f
mail("$email","Thank you for contacting us", "Hi $firstname,\n
Thank you for contacting us!\n
We will respond to your enquiry as soon as possible.\n\n\n
Thanks.;
$msg.="Thank you!<br />Your enquiry has been submitted and we will respond as soon as we can.";
}
?>
Any help with how to integrate email validation into that would be greatly appreciated. Of course, if someone knows of a better way to do email validation I'm game for that too.
Thanks.
|