I know this has been asked before but I really can't relate any of the threads to my code. A'll I'm trying to do is get this quick PHP form to echo the error messages in the form as appose to a new page. (I'm sure you know what I mean)
The Form:
<form method="post" action="/includes/php/forms/contact/validation/contact.php" name="contactform" id="contactform" class="contact-form">
<h2 class="form-title">Initial Information</h2>
<fieldset>
<!-- full-name -->
<section class="form-section">
<label name="first" class="left">Your Full Name</label>
<p class="right required">*</p>
<input name="name" id="name" type="text" value="">
</section>
</fieldset>
<input class="form-submit" id="submit" value="Submit" type="submit">
</form>
The PHP:
// Initial Information.
$name = $_POST['name'];
// Error Messages
if(trim($name) == '') {
echo '<div class="error_message">Attention! You must enter your full name.</div>';
exit();
}
I've tried to cut down the code to the relevant parts, but what's confusing me is I can't find an example of the if(trim etc...) being used in any tutorials, so I'm not entiely sure that's correct.
Any info on where to go from here would be appreciated.