<?php
$errors = '';
$myemail = 'hands@global.saraya.com';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['companyname']) ||
empty($_POST['email']) ||
empty($_POST['country']) ||
empty($_POST['department']) ||
empty($_POST['industry']) ||
empty($_POST['message']) ||
empty($_POST['agree']))
{
$errors .= "Error: all fields are required";
}
$name = $_POST['name'];
$companyname = $_POST['companyname'];
$email = $_POST['email'];
$country = $_POST['country'];
$department = $_POST['department'];
$industry = $_POST['industry'];
$message = $_POST['message'];
$agree = $_POST['agree'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Sanistar Site Contact form submission: $companyname";
$email_body = "You have received a new message from the site www.sanistar.pro ".
" Here are the details:\n Name: $name \n Company Name: $companyname \n Email: $email \n Country: $country \n Department: $department \n Industry: $industry \n Message: \n $message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-thank-you.html');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Contact form handler</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>
</body>
</html>
All system for education purposes only. For more tools: Telegram @jackleet