Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])) {
- $email_to = "contact@JTDevelopment.org";
- $email_subject = "Potential Web Order";
- function died($error) {
- echo "We're sorry, but we weren't able to submit this request.";
- echo "The error appears to be: "."<br>";
- echo $error."<br /><br />";
- echo "Please go back and fix these errors.<br /><br />";
- die();
- }
- if(!isset($_POST['firstname']) ||
- !isset($_POST['lastname']) ||
- !isset($_POST['email']) ||
- !isset($_POST['company']) ||
- !isset($_POST['message'])
- !isset($_POST['budget'])) {
- died('We are sorry, but there appears to be a problem with the form you submitted.');
- }
- $firstname = $_POST['firstname']; // required
- $budget = $_POST['budget']; // required
- $lastname = $_POST['lastname']; // required
- $email_from = $_POST['email']; // required
- $company = $_POST['company']; // required
- $website = $_POST['website']; // not required
- $comments = $_POST['message']; // required
- $error_message = "Error";
- $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
- if(!preg_match($email_exp,$email_from)) {
- $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
- }
- $string_exp = "/^[A-Za-z .'-]+$/";
- if(!preg_match($string_exp,$firstname)) {
- $error_message .= 'The First Name you entered does not appear to be valid.<br />';
- }
- if(!preg_match($string_exp,$lastname)) {
- $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
- }
- if(strlen($comments) < 2) {
- $error_message .= 'The Comments you entered do not appear to be valid.<br />';
- }
- if(strlen($error_message) > 0) {
- died($error_message);
- }
- $email_message = "Form details below.\n\n";
- function clean_string($string) {
- $bad = array("content-type","bcc:","to:","cc:","href");
- return str_replace($bad,"",$string);
- }
- $email_message .= "First Name: ".clean_string($first_name)."\n";
- $email_message .= "Last Name: ".clean_string($last_name)."\n";
- $email_message .= "Email: ".clean_string($email_from)."\n";
- $email_message .= "Company: ".clean_string($company)."\n";
- $email_message .= "Details:: ".clean_string($message)."\n";
- $email_message .= "Budget: ".clean_string($budget)."\n";
- $headers = 'From: '.$email_from."\r\n".
- 'Reply-To: '.$email_from."\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- @mail($email_to, $email_subject, $email_message, $headers);
- ?>
- Thank you for contacting us. We will be in touch with you very soon.
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement