if (isset($_POST['firstname'])) {
if (validate())
sendMail();
else {
form(1);
}
}
else {
form(0);
}
function sendMail() {
global $lang;
$to = 'info@aviton.com, alanonmobile@gmail.com';
$subject = 'Enquiry from Aviton.com';
$header = 'From: ' . $_POST['email'] . "\r\n" .
'Reply-To: ' . $_POST['email'] . "\r\n" .
'X-Mailer: PHP/' .phpversion();
$body = 'Title: ' . $_POST['title'] . "\r\n" .
'First Name: ' . $_POST['firstname'] . "\r\n" .
'Last Name: ' . $_POST['lastname'] . "\r\n" .
'Company: ' . $_POST['company'] . "\r\n" .
'Email: ' . $_POST['email'] . "\r\n" .
'Address Line 1: ' . $_POST['address1'] . "\r\n" .
'Address Line 2: ' . $_POST['address2'] . "\r\n" .
'City: ' . $_POST['city'] . "\r\n" .
'State: ' . $_POST['state'] . "\r\n" .
'Country: ' . $_POST['country'] . "\r\n" .
'Phone: ' . $_POST['phone'] . "\r\n" .
'Fax: ' . $_POST['fax'] . "\r\n" .
'Message: ' . $_POST['comment'] . "\r\n";
mail($to, $subject, $body, $header);
?>
THANK YOU.
Your enquiry has been sent, one of our representatives
will respond to your message as soon as possible.
Click here to return to the Homepage.
}
function validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
$isValid = false;
}
else
{
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64)
{
// local part length exceeded
$isValid = false;
}
else if ($domainLen < 1 || $domainLen > 255)
{
// domain part length exceeded
$isValid = false;
}
else if ($local[0] == '.' || $local[$localLen-1] == '.')
{
// local part starts or ends with '.'
$isValid = false;
}
else if (preg_match('/\\.\\./', $local))
{
// local part has two consecutive dots
$isValid = false;
}
else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
{
// character not valid in domain part
$isValid = false;
}
else if (preg_match('/\\.\\./', $domain))
{
// domain part has two consecutive dots
$isValid = false;
}
else if
(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
str_replace("\\\\","",$local)))
{
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/',
str_replace("\\\\","",$local)))
{
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain,"MX") ||
Checkdnsrr($domain,"A")))
{
// domain not found in DNS
$isValid = false;
}
}
return $isValid;
}
function validate() {
if (!strlen($_POST['firstname']) || !strlen($_POST['lastname']) || !strlen($_POST['email']) || !strlen($_POST['phone']) || !validEmail($_POST['email']))
return 0;
else
return 1;
}
function form($error) {
global $lang;
?>
}
?>