I created very simple message form and there is some problem. At least message is send and there is display thank you page, but there is Notice: Undefined index: name in public_www/n..../contact-form-handler.php on line 14 and another one error is that name is not send.
Thanks for any hint
<form class='contact_form' method="POST" action="contact-form-handler.php" >
<ul>
<li>
<label for="name" >Name:</label>
<input type="text" id="name" />
</li>
<li>
<label for="email" id="email">Email:</label>
<input type="email" name="email" />
</li>
<li>
<label for="message" id="message">Message:</label>
<textarea name="message" cols="40" rows="6" required ></textarea>
</li>
<li>
<button class="submit" value="submit">Submit Form</button>
</li>
</ul>
</form>
and PHP is:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$to = "test@test.com";
$subject = "Contact";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo include( "contact-form-thank-you.html" );
mail($to, $subject, $body);
} else {
echo include( "contact-form-error.html" );
}
?>