0

I programmed a contact-form in PHP and HTML and I don't know what I did wrong.

EDIT: I looked at this post but it doesn't help me because I am new to PHP and I feel like I need personal help with my code.

Here is my HTML:

<div class="contact-form">


<form id="contact-form" method="post" action="contact-form-handler.php">
            <input name="name" type="text" class="form-control" placeholder="Your Name" required>

            <br>
            <input name="email" type="email" class="form-control" placeholder="Your Email">
            <br>

            <textarea name="message" class="form-control" placeholder="Message" row="4" required></textarea><br>

            <input type="submit" class="form-control" value="SEND MESSAGE">

        </form>
</div>

Here is my PHP:

<?php
    $name = $_POST['name'];
    $visitor_email = $_POST['email'];
    $message = $_POST['message']

    $email_from = 'Email1@whatever.com';
    $email_subject = "New Form Submission";
    §email_body = "User Name: $name.\n".
                    "User Email: $visitor_email.\n".
                        "User Message: $message.\n".

    $to = "Email2@whatever.com";

    $headers = "From: $email_from \r\n";

    $headers .= "Reply-To: $visitor_email \r\n";

    mail($to,$email_subject,$email_body,$headers);

    echo "Your Message has been sent.";

    header("location: index.html");
?>

When you send the message, you get redirected to the PHP file but the page goes blank and the email is not being send. Can anyone help me?

0 Answers0