function check_email_address($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)){ // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } if(strpos($email, 'businesscapitaladvisor.com') !== false){ return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } function check_email_mx($email) { if((preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) || preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) { $host = explode('@', $email); if(checkdnsrr($host[1].'.', 'MX') ) return true; if(checkdnsrr($host[1].'.', 'A') ) return true; if(checkdnsrr($host[1].'.', 'CNAME') ) return true; } return false; } if ($_POST["submit"]=="Submit"){ $passed = true; $errors = 0; if($_POST["email"]!="pinkdaisy333@hotmail.com"){ include("spam_stopper.php"); } $name = $_POST["name"]; $business_name = $_POST["business_name"]; $email = $_POST["email"]; $phone = $_POST["phone"]; $comments = $_POST["comments"]; $comments=nl2br($comments); $comments=stripslashes($comments); if (!check_email_address($email)) { $errors++; }else{ if (!check_email_mx($email)) { $errors++; } } if(($errors==0)&&($passed==true)){ $message="
Name: | $name |
Business Name: | $business_name |
Email: | |
Phone: | $phone |
Comments: | $comments |
P.O. Box 2134
Peterborough, ON
K9J 7Y4
Telephone: (705) 772-1073
Email: info@reddiamonddesigns.com