PHP Contact Form won't send from mobile device -
i pulled code off site use in various forms on website. had friend text me today saying "hey tried contact through website." set off alarm in head... "you tried?" went heavy test mode, , seems thing forms don't emailed account when submit them phone. worst part site treats submit if form sent. there no error message. here code: `
$email_to = "info@optiprintdesign.com"; $email_subject = "contact form message - opti print , design"; function died($error) { echo "we sorry, there error(s) found form submitted. "; echo "these errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "please go , fix these errors.<br /><br />"; die(); } if(!isset($_post['username']) || !isset($_post['usercompany']) || !isset($_post['email']) || !isset($_post['userphone']) || !isset($_post['usersite']) || !isset($_post['userlocation']) || !isset($_post['comments'])) { died('we sorry, there appears problem form submitted.'); } $username = $_post['username']; $usercompany = $_post['usercompany']; $email_from = $_post['email']; $userphone = $_post['userphone']; $usersite = $_post['usersite']; $userlocation = $_post['userlocation']; $comments = $_post['comments']; $error_message = ""; $email_exp = '/^[a-za-z0-9._%-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'the email address entered not appear valid.<br />'; } $string_exp = "/^[a-za-z .'-]+$/"; if(!preg_match($string_exp,$username)) { $error_message .= 'the name entered not appear valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'the comments entered not appear valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "name: ".clean_string($username)."\n"; $email_message .= "company: ".clean_string($usercompany)."\n"; $email_message .= "email: ".clean_string($email_from)."\n"; $email_message .= "phone: ".clean_string($userphone)."\n"; $email_message .= "website: ".clean_string($usersite)."\n"; $email_message .= "location: ".clean_string($userlocation)."\n"; $email_message .= "comments: ".clean_string($comments)."\n"; @mail($email_to, $email_subject, $email_message, $headers); ?>
please read on error control operators
php supports 1 error control operator: @ sign (@). when prepended expression in php, error messages might generated expression ignored.
Comments
Post a Comment