I'm trying to get this PHP form to work, every time I submit the form the browser returns the else statement but doesn't execute the above if statement, what have I missed?
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$subject = $_POST['subject'];
$mail = $_POST['mail'];
$message = $_POST['message'];
$to = '***.*****@gmail.com';
$subject='Form submission';
$message="Name: ".$name."\n". "Wrote the following: "."\n\n".$message;
$headers="From: ".$mail;
if (mail($to, $subject, $message, $headers)) {
echo "<h1>Sent Successfully! Thank you"." ".$name.", I will contact you shortly.</h1>";
}
else {
echo "Something went wrong! Contact me at alec.dannmayr@gmail.com";
}
}
?>
<input type="text" name="name" placeholder="Full Name">
<input type="text" name="mail " placeholder="Email">
<input type="text" name="subject" placeholder="Subject">
<textarea name="message" placeholder="Message" cols="30" rows="10"></textarea>
<input type="submit" name="submit"></input>
</form>