session_start();
$title = "MorningWell - contact us";
include_once '/home/httpd/common/sendmail.php';
include ('header.php');
$alert = "All fields required";
if ($_POST["SubContact"])
{
$select = $_POST["contactTo"];
$name = $_POST["contactName"];
$email = $_POST["contactEmail"];
$comments = $_POST["contactMessage"];
$post_imgcode=$_POST["post_imgcode"];
$session_imgcode=$_SESSION[imgcode];
//destroy imgcode session data
unset($_SESSION[imgcode]);
if ($select == "0") $realSelect = false;
else $realSelect = $select;
if (TestForm ($realSelect, $name, $email, &$alert, $post_imgcode,$session_imgcode))
{
$mess_body .= "Name: $name\n"
."E-mail: $email\n***********\n"
."Comments:\n\n$comments\n***********";
SendContactMail ($name, $email, $realSelect, $mess_body);
?>
}
else
{
if ($_POST["contactTo"])
{
if ($_POST["contactTo"] == "Product info") $product = "selected";
else $product = "";
if ($_POST["contactTo"] == "Marketing") $marketing = "selected";
else $marketing = "";
if ($_POST["contactTo"] == "Other") $other = "selected";
else $other = "";
}
if ($_POST["contactName"]) $valueName = $_POST["contactName"];
else $valueName = "";
if ($_POST["contactEmail"]) $valueEmail = $_POST["contactEmail"];
else $valueEmail = "";
if ($_POST["contactMessage"]) $valueMess = $_POST["contactMessage"];
else $valueMess = "";
?>
}
}
else
{
?>
}
include ('footer.php');
function TestForm ($select, $name, $email, $alert,$post_imgcode,$session_imgcode)
{
$checkedEmail = UTILS_CheckEmail($email, &$alert);
if (!$select ){ $alert="Please specify recipient in \"To:\" field.";return false;}
elseif (!$name){ $alert="Please enter your name.";return false;}
elseif (!$checkedEmail){ $alert="E-mail syntax is incorrect.";return false;}
elseif (!$post_imgcode){ $alert="Please Enter the image code.";return false;}
elseif (md5(strtoupper($post_imgcode)) != $session_imgcode){
$error = "You entered incorrect image code.";return false;
}
else return true;
}
function SendContactMail ($name, $reply, $subject, $addMessage)
{
$subject="Baby Skin Care Automatic Message -- ".$subject;
$message = "$subject\n\n$addMessage";
smail('maxine@hearthstoneonline.com', 'Maxine', $reply, $name, $reply, $subject, $message);
smail('ab@hearthstoneonline.com', 'Amir', $reply, $name, $reply, $subject, $message);
}
function pregtrim($str)
{
return preg_replace("/[^\x20-\xFF]/","",@strval($str));
}
function UTILS_CheckEmail($mail )
{
$mail=trim(pregtrim($mail));
if (!preg_match("/^[a-z0-9_-]{1,20}@(([a-z0-9-]+\.)+(com|net|org|mil|".
"edu|gov|arpa|info|biz|inc|name|[a-z]{2}|[a-z]{3})|[0-9]{1,3}\.[0-9]{1,3}\.[0-".
"9]{1,3}\.[0-9]{1,3})$/is",$mail)){return false;}
return true;
}
?>