html - Contact form PHP shows blank -
i took standard form use included comments are. website don't need comments left email , url in it. when remove related comments in php file shows blank page, not error.
here's code:
<?php if(isset($_post['email'])) { // change 2 lines below $email_to = "email@email.com"; $email_subject = "new contact"; function died($error) { // error code can go here 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(); } // validation expected data exists if(!isset($_post['email']) || !isset($_post['url'])) || { died('we sorry, there appears problem form submitted.'); } $email_from = $_post['email']; // required $url = $_post['url']; // not required $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 />'; } 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 .= "email: ".clean_string($email_from)."\n"; $email_message .= "url: ".clean_string($url)."\n"; // create email headers $headers = 'from: '.$email_from."\r\n". 'reply-to: '.$email_from."\r\n" . 'x-mailer: php/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- place own success html below --> success <?php } die(); ?>
you have ||
in if condition. remove , should work.
if(!isset($_post['email']) || !isset($_post['url'])) || { ^^^^ died('we sorry, there appears problem form submitted.'); }
Comments
Post a Comment