$message = ""; $emailclass = "basictext"; $firstname = ""; $surname = ""; $email = ""; $telephone = ""; $comments = ""; if ($_POST['process'] == 5) { // We get here if submit button was pressed $pattern = '/^[a-z0-9!#$%&*+-=?^_`{|}~]+(\.[a-z0-9!#$%&*+-=?^_`{|}~]+)*'; $pattern.= '@([-a-z0-9]+\.)+([a-z]{2,3}'; $pattern.= '|info|arpa|aero|coop|name|museum|mobi|travel|jobs|post|asia|kids|mail)$/ix'; // $pattern = '/.*@.*\..*/'; $email = $_POST['txt_email']; $firstname = htmlentities($_POST['txt_firstname']); $surname = htmlentities($_POST['txt_surname']); $telephone = htmlentities($_POST['txt_telephone']); $comments = htmlentities($_POST['txt_message']); if (preg_match($pattern, $_POST['txt_email']) > 0) { // We get here if the email address passes inspection // We still need to validate other 2 fields now. $substring1 = 'tp:'; $cleanfirstname = strpos($firstname, $substring1); $cleansurname = strpos($surname, $substring1); $cleantelephone = strpos($telephone, $substring1); $cleancomments = strpos($comments, $substring1); if (($cleanfirstname === false) AND ($cleansurname === false) AND ($cleantelephone === false) AND ($cleancomments === false)) { // We get here if there is no tp: in the name field or the comments field .. ie no urls // So we can go ahead and send the email. $too_addr = "delanelkennels@gmail.com, boltonfourie@gmail.com"; $mail2_body = "I want a Puppy!!"; $mail2_body .= "\n\nFirst Name : ".$firstname; $mail2_body .= "\nSurname : ".$surname; $mail2_body .= "\nEmail Address : ".$email; $mail2_body .= "\nTelephone No : ".$telephone; $mail2_body .= "\nQuestion : ".$comments; $mail2_body .= "\n\nThank you\n"; mail($too_addr,"Website Enquiry",$mail2_body,"From: ".$email."\n"); header("location: thankyou.htm"); } // We get here if the dude is a thneaky thpammer (ie. he put in a URL into the name or email // fields .. and we dont even tell him why the form is failing to submit. // We make it look like a problematic email address. WE HATE POND THCUM THPAMMERTH. } // We get here if the email address does not pass inspection $message = "Please re-enter your information"; $firstname = $_POST['txt_firstname']; $surname = $_POST['txt_surname']; $telephone = $_POST['txt_telephone']; $comments = $_POST['txt_message']; $emailclass = "errortext"; } ?>