(432) 684-8200
info@anthemoil.com

send_email

<?php

//Start or resume user session
session_start();

function died($error) {
//throw new Exception($error); //use for testing of any error message which is appearing unexpectedly
$_SESSION[‘SuccessfulForm’] = ‘N’;
header( ‘http://anthemoil.com/contact-us/’ );
exit;
}

$trimmedFN = trim($_POST[‘q1_Full Name’]);

if(isset($_POST[‘q1_Full Name’]) && !empty($trimmedFN)) {

$email_to = “anupam@amthemabroad.com”; //Used for production
//$email_to = “blakecliffordmorgan@gmail.com”; //Used for testing
$email_from = “anupam@amthemabroad.com”;

$email_subject = “Anthem Oil: Website Form Submission”;

// validation expected data exists
if(!isset($_POST[‘q1_Full Name’]) ||) {
died(‘It appears you did not fill out all required fields.’);
}

$error_message = “”;
$email_exp = ‘/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/’;
if(!empty($_POST[‘q4_Confirm Email’]) && !preg_match($email_exp,$_POST[‘q4_Confirm Email’])) {
$error_message .= ‘The Email Address you entered does not appear to be valid.<br />’;
}

if((!empty($_POST[‘q4_Confirm Email’]) || !empty($_POST[‘confirm_email’])) && strtoupper(trim($_POST[‘confirm_email’])) !== strtoupper(trim($_POST[‘q4_Confirm Email’]))) {
$error_message .= ‘The Email Addresses you entered do not match.<br />’;
}

if(strlen($error_message) > 0) {
died($error_message);
}

$email_message = “<b><u><h2>Form details below: </h2></u></b><br /><br />”;

function clean_string($string) {
$string = trim($string);
$bad = array(“content-type”,”bcc:”,”to:”,”cc:”,”href”);
return str_replace($bad,””,$string);
}

$email_message .= “<b>Name:</b> “.clean_string($_POST[‘q1_Full Name’]).”<br />”;
$email_message .= “<b>Mailing Address:</b> “.clean_string($_POST[‘mailing_address’]).”<br />”;
$email_message .= “<b>City:</b> “.clean_string($_POST[‘city’]).”<br />”;
$email_message .= “<b>State:</b> “.clean_string($_POST[‘state’]).”<br />”;
$email_message .= “<b>Zip Code:</b> “.clean_string($_POST[‘zip_code’]).”<br />”;
$email_message .= “<b>Day Time Phone:</b> “.clean_string($_POST[‘day_time_phone’]).”<br />”;
$email_message .= “<b>Evening Time Phone:</b> “.clean_string($_POST[‘evening_time_phone’]).”<br />”;
$email_message .= “<b>Fax:</b> “.clean_string($_POST[‘fax’]).”<br />”;
$email_message .= “<b>Email:</b> “.clean_string($_POST[’email’]).”<br />”;
$email_message .= “<b>Confirmed Email:</b> “.clean_string($_POST[‘confirm_email’]).”<br />”;
$email_message .= “<b>How Did You Hear About Us:</b> “.clean_string($_POST[‘letter’]).”<br />”;
$email_message .= “<b>County & State Where Property Is Located:</b> “.clean_string($_POST[‘TX’]).”<br />”;
$email_message .= “<b>Estimation Of Monthly Income:</b> “.clean_string($_POST[‘estimation_of_the_monthly_income’]).”<br />”;
$email_message .= “<b>Do You Have A Copy Of The Possession Deed Or From Who You Acquired It:</b> “.clean_string($_POST[‘you_have_a_copy_of_your’]).”<br />”;
$email_message .= “<b>Do You Have A Copy Of Your Tax Statement & Have All Taxes Been Paid To Date:</b> “.clean_string($_POST[‘tax_statement’]).”<br />”;
$email_message .= “<b>Additional Information, Questions, Or Comments:</b> “.clean_string($_POST[‘additional’]).”<br />”;

// create email headers
$headers = ‘From: ‘.$email_from.”\r\n”.
‘Reply-To: ‘.$email_from.”\r\n” .
“Content-Type: text/html; charset=ISO-8859-1\r\n”.
‘X-Mailer: PHP/’ . phpversion();
try {
@mail($email_to, $email_subject, $email_message, $headers);
}
catch(Exception $e) {
died($e->getMessage());
}

$_SESSION[‘SuccessfulForm’] = ‘Y’;
header( ‘http://anthemoil.com/contact-us/’ );
exit;

} else {
died(‘Form does not appear to have been submitted’);
}