 |
Contact Us
|
|
//setting
$to = "info@footprintsfinearts.com.my";
$thank_you_message = "Thank you for your message. We will contact you soon";
//anti spammer function
if($_SERVER['REQUEST_METHOD'] != "POST" and $_SERVER['REQUEST_METHOD']!=""){
echo("Unauthorized attempt to access page.");
exit;
}
//Contact form information
$contact_name = $_POST['name'];
$enquiry = $_POST['enquiry'];
$email = $_POST['email'];
$phone = $_POST['telno'];
$subject = "From http://www.footprintsfinearts.com.my";
//checking for valid email
function is_valid_email($email) {
return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s]+\.+[a-z]{2,6}))$#si', $email);
}
//checking for spammer code
function contains_bad_str($str_to_test) {
$bad_strings = array(
"content-type:"
,"mime-version:"
,"multipart/mixed"
,"Content-Transfer-Encoding:"
,"bcc:"
,"cc:"
,"to:"
);
foreach($bad_strings as $bad_string) {
if(eregi($bad_string, strtolower($str_to_test))) {
echo "$bad_string found. Suspected injection attempt - mail not being sent.";
exit;
}
}
}
function contains_newlines($str_to_test) {
if(preg_match("/(%0A|%0D|\\n+|\\r+)/i", $str_to_test) != 0) {
echo "newline found in $str_to_test. Suspected injection attempt - mail not being sent.";
exit;
}
}
if (!is_valid_email($email)) {
//echo 'Invalid email';
$error .= "Invalid email address ";
$go=1;
}
contains_bad_str($email);
contains_bad_str($enquiry);
contains_newlines($email);
//checking for empty fields
if ($contact_name==""){
$error = "Please enter your name ";
$go=1;
}
if ($phone==""){
$error .= "Please enter your telephone number ";
$go=1;
}
if ($email==""){
$error .= "Please enter your email address ";
$go=1;
}
if ($enquiry==""){
$error .= "Please write your message ";
$go=1;
}
if ($go<1){
$message = "Name : $contact_name\n";
$message .= "Telephone : $phone\n";
$message .= "Email : $email\n";
$message .= "Enquiry : $enquiry\n";
mail($to, $subject, $message, "From: $contact_name<$email>");
echo $thank_you_message;
}
else {
echo "Error: $error ";
}
if ($error){
?>
} ?>
|
|
|
|
|
 |
 |