Email;
$from = $admin->Email;
//session_start();
$errors = '';
$user_name = '';
$address = '';
$city = '';
$country = '';
$phone = '';
$mobile = '';
$fax = '';
$user_email = '';
$comments = '';
if(isset($_POST['submit']))
{
$user_name = $_POST['user_name'];
$address = $_POST['address'];
$city = $_POST['city'];
$country = $_POST['country'];
$phone = $_POST['phone'];
$mobile = $_POST['mobile'];
$fax = $_POST['fax'];
$user_email = $_POST['user_email'];
$comments = $_POST['comments'];
///------------Do Validations-------------
if(empty($user_name)||empty($country)||empty($phone)||empty($user_email)||empty($comments))
{
$errors .= "Name, Country, Phone, Email, Comments are required fields.
";
}
if(IsInjected($user_email))
{
$errors .= "\n Bad email value!";
}
if(empty($_SESSION['6_letters_code'] ) ||
strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
$errors .= "The captcha code does not match!";
}
$oper_result = array();
if(empty($errors))
{
//send the email
$to = $our_email;
$subject="Contact Us form submission from website";
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$body = "A visitor submitted below details through contact form from bdis website:\n\n\n".
"Name: $user_name\n".
"Address: $address\n".
"City: $city\n".
"Country: $country\n".
"Phone No: $phone\n".
"Mobile: $mobile\n".
"Fax: $fax\n".
"Email: $user_email\n\n".
"Message:\n".
"$comments\n\n\n".
"Posted from IP: $ip\n";
$headers = "From: $from \r\n".
"Reply-To: $user_email \r\n";
$send_feedback = mail($to,$subject,$body,$headers);
if($send_feedback){
$oper_result['validation_message'] = TRUE;
$oper_result['validation_message_text'] = "Your Message has been send Successfully.
Thanks for your Message. We will get back you soon...";
$oper_result['validation_message_type'] = 'success';
$_SESSION['Message'] = $oper_result;
header('Location: contact-us.html');
exit();
}else{
$errors = 'Error occured while sending Feedback details...';
$oper_result['validation_message'] = TRUE;
$oper_result['validation_message_text'] = $errors;
$oper_result['validation_message_type'] = 'error';
$_SESSION['Message'] = $oper_result;
//echo('Error occured while sending Feedback details...');
}
}else{
$oper_result['validation_message'] = TRUE;
$oper_result['validation_message_text'] = $errors;
$oper_result['validation_message_type'] = 'error';
$_SESSION['Message'] = $oper_result;
}
}
// Function to validate against any email injection attempts
function IsInjected($str)
{
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
?>
::Buzwair Dry Ice Services::