Contact us
if ($formok != "1") { include('the_form.php'); //echo $_SESSION['captcha_code']; //echo $_POST['captcha_code']; } //if form ok then submit it if ($formok == "1") { echo "Your message has been sent to the secretary.
"; } ?>session_start(); // Functions function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } // Define the variables and set to empty values $yourname = $email = $tel = $message = ""; $yournameErr = $emailErr = $telErr = $messageErr = $captchaErr = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $formok = 1; } // Getting our form variables from GET method and removing any threats if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["yourname"])) { $yournameErr = "Your Name is required"; $formok++; } else { $yourname = test_input($_POST["yourname"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$yourname)) { $yournameErr = "Only letters and white space allowed"; $formok++; }} if (empty($_POST["email"])) { $emailErr = "Email is required"; $formok++; } else { $email = test_input($_POST["email"]); // check if e-mail address is well-formed if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; $formok++; } } // if (empty($_POST["tel"])) { // $telErr = ""; // } else { $tel = test_input($_POST["tel"]); // check if tel is well-formed if (preg_match('/[^0-9 +-]/',$tel)) { $telErr = "Only numbers allowed"; $formok++; } //} if (empty($_POST["message"])) { $messageErr = "You need to enter a message"; $formok++; } else { $message = test_input($_POST["message"]); } if(isset($_POST['captcha_code']) && isset($_SESSION['captcha_code'])){ // check user answer is equal to session captcha code if($_POST['captcha_code'] != $_SESSION['captcha_code']){ $captchaErr = "Wrong answer entered - Try again"; $formok++; } } //echo "meh"; //if form ok then submit it $blockword = strpos($message, 'intimate'); // if ($formok == 1 AND $email != "eric.jones.z.mail@gmail.com" AND $blockword === false) { if ($formok == 1 AND !in_array($email, array("eric.jones.z.mail@gmail.com","ericjonesmyemail@gmail.com")) AND $blockword === false) { $to = "robfakes35@gmail.com"; //$to = "humphandreia@gmail.com"; $subject = "Contact from Wessex Winter Caravanners Website"; $txt = "Name: $yourname \r\n Email: $email \r\n Tel: $tel \r\n Message: $message"; $headers = "From: no-reply@wessexwintercaravanners.co.uk\r\n"; $headers .= 'Cc: robfakes35@gmail.com' . "\r\n"; $headers.= "MIME-Version: 1.0\r\n"; $headers.= "Content-Type: text/plain; charset=utf-8\r\n"; $headers.= "X-Priority: 1\r\n"; mail($to,$subject,$txt,$headers); //$logfile = fopen("contact_log_3859034849032.txt", "w") or die("Unable to open file!"); //fwrite($myfile, $txt); //fclose($myfile); } } ?>
Contact us
if ($formok != "1") { include('the_form.php'); //echo $_SESSION['captcha_code']; //echo $_POST['captcha_code']; } //if form ok then submit it if ($formok == "1") { echo "Your message has been sent to the secretary.
"; } ?>