Trying to get the error messages of $missing to appear in the form div with id error, and if the form is filled out correctly display the $complete message into div with id success.
<?php
$error = false;
$missing = "";
if ($_POST) {
$complete = "<p><strong>Thank you!</strong> Your message was sent,
we'll get back to you ASAP!</p>";
if (filter_var($_POST["email"], FILTER_VALIDATE_EMAIL) === false {
$missing .= "A vaild email address is required.<br>";
$error = true;
}
if (!$_POST['subject']) {
$missing .= "A subject field is required.<br>";
$error = true;
}
if (!$_POST['content']) {
$missing .= "A content field is required.<br>";
$error = true;
}
if ($error) {
$missing = "<p>". $missing."</p>";
} else {
$complete;
}
}
?>
This is the HTML form where trying to display.
<form method="post">
<h1>Get in touch!</h1>
<div id="error" class="alert alert-danger" role="alert">
<? echo $missing; ?></div>
<div id="success" class="alert alert-success" role="alert"><? echo $complete; ?></div>
Can't really see where i'm going wrong here, any help would be amazing. Thanks.
else { $complete;- and there's code missing in here, as in the (form) elements inputs and the closing form</form>tag. So we don't know if that's at fault or not. This in addition to Chris' comment.