I have a simple form (below), I want to send the Name field in email but POST is empty.
HTML Form:
<form action="contact.php" method="post">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
PHP:
<?php
if (isset($_POST['name'])){
$to = "example@example.com";
$subject = "Test subject";
$txt = $_POST['name'];
$txt .= "test txt";
$headers = "From: example2@example2.com" . "\r\n" .
"CC: somebodyelse@example.com";
if (mail($to,$subject,$txt,$headers)){
echo "succes";
}else{
echo "failed";
}
} else {
echo "Name is required!";
}
?>
Does anyone has an idea what could be wrong? I have other forms on this server and they are working fine.