0

I am not receiving emails from my php form / html. I am new to making these forms, and I am wondering where I went wrong. The form sets up fine on a live site, and the submit button takes me back to the home page, which is what I want. Would anyone be able to help me figure out why I am not receiving the emails?

Here is the html :

`

<section class="contact-container">
            <div class="container mtb">
                <div class="row">
                    <div class="col-md-8 wow fadeInLeft">
                        <h4>Get in touch</h4>
                        <hr>
                            <p>Leave a comment, review, or general musings.</p><br />



<form id="contact_form" action="websitehere"  method="post">
    <label>Name: <input class="textfield" name="name" type="text" value="" /></label> 
    <label>Email: <input class="textfield" name="email" type="text" value="" /></label> 
    <label>Message: <textarea class="textarea" cols="45" name="message" rows="5"></textarea></label> 
    <input class="button" name="submit" type="submit" value="Submit" />
</form>

</div>

And here is the PHP:

<?php
    if (isset($_POST["submit"])) {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        $human = intval($_POST['human']);

        $to = 'emailaddress@email.com'; 
        $subject = 'Message for the author ';

        $body = "From: $name\n E-Mail: $email\n Message:\n $message";

        // Check if name has been entered
        if (!$_POST['name']) {
            $errName = 'Please enter your name';
        }

        // Check if email has been entered and is valid
        if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
            $errEmail = 'Please enter a valid email address';
        }

        //Check if message has been entered
        if (!$_POST['message']) {
            $errMessage = 'Please enter your message';
        }
        //Check if simple anti-bot test is correct
        if ($human !== 5) {
            $errHuman = 'Your anti-spam is incorrect';
        }

// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
    if (mail ($to, $subject, $body, $from)) {
        $result='<div class="alert alert-success">Thank You! I will be in touch</div>';
    } else {
        $result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
    }
}
    }
?>

1 Answers1

0

You forgot human in your html code. Also, make sure you are not sending this email to a Yahoo email because they have problems with php mails since December 4th. If that doesn't fix your problem, this might help you: http://email.about.com/od/emailprogrammingtips/qt/How_to_Send_Email_from_a_PHP_Script.htm

Komninos
  • 96
  • 1
  • 1
  • 10