3 thoughts on “How To Create A Contact Form | P.3

  1. I really like your tutorials, you explain very detailed.
    But this Form doesn’t seem to work for me, I get this when i press send:

    “; echo $error. ”

    “; echo “Please go back and fix these errors.
    “; die(); } // validation if(!isset($_POST[‘name’]) || !isset($_POST[’email’]) || !isset($_POST[‘comments’])){ died(‘We are sorry but there appears to be a problem with the form you submitted.’); } $name = $_POST[‘name’]; $email = $_POST[’email’]; $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)){ $error_message .= ‘The Email address you entered does not appear to be valid.
    ‘; } $string_exp = “/^[A-Za-z.’-]+$/”; if (!preg_match($string_exp, $name)){ $error_message .= ‘The Name you entered does not appear to be valid.
    ‘; } if(strlen($comments) 0 ){ died($error_message); } $email_message = “Form Details below.nn”; function clean_string($string){ $bad = array(“content-type”, “bcc:”, “to:”, “cc:”, “href”); return str_replace($bad, “”, $string); } $email_message .= “Name:” . clean_string($name) . “n”; $email_message .= “Email:” . clean_string($email) . “n”; $email_message .= “Comments:” . clean_string($comments) . “n”; // create email headers $headers = ‘From: ‘ .$email_From . “rn”. ‘Reply-To:’ .$email. “rn” . ‘X-Mailer: PHP/’ . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> Thank you for contacting us. We will be in touch with you shortly.
    Please click here to go back to the form.

    So I’m obviously new to php and I dont know what to do ^^

Leave a Reply

Your email address will not be published. Required fields are marked *