I don't get any errors. I used to get Undefined index/variable errors before but I fixed that with isset(). I fill the form out and hit submit but nothing shows up but a blank white screen.
This is my PHP code:
<?php
$name = isset($_POST['name']) ? $_POST['name'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
$from = 'From: ContactForm';
$to = 'email@email.com';
$subject = 'Hello';
$verify = $_POST['verify'];
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if (isset($_POST["submit"]) && $verify == '4') {
if (mail ($name, $email, $message)) {
echo '<p>Your message has been sent!</p>';
}
else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
else if (isset($_POST["submit"]) && verify != '4') {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}
?>
This is my HTML code:
<form action="pages/mail.php" method="post">
<div class="col-md-12">
<div class="form-group">
<label for="name" class="sr-only">Name</label>
<input placeholder="Name" id="name" type="text" class="form-control input-lg">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="email" class="sr-only">Email</label>
<input placeholder="Email" id="email" type="text" class="form-control input-lg">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="message" class="sr-only">Message</label>
<textarea placeholder="Message" id="message" class="form-control input-lg" rows="3"></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input id="submit" type="submit" class="btn btn-primary btn-lg " value="Send">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="verify" class="sr-only">Verify</label>
<input name="verify" placeholder="What is 2+2" class="form-control input-lg">
</div>
</div>
</form>