Ik heb het geprobeerd met elke input zijn eigen fout variabelen te geven, maar dat was geen succes. Iemand die een oplossing weet?
Ik gebruik deze controle:
$aFout = array();
if(empty($_POST['firstname'])) {
$aFout[] = 'Er is geen voornaam ingevuld.';
unset($voornaam);
$fout['text']['firstname'] = TRUE;
$fout['input']['firstname'] = TRUE;
}
if(!empty( $aFout ))
{
$errors = '
<div id="errors">
<ul>';
foreach($aFout as $sFout)
{
$errors .= " <li>".$sFout."</li>\n";
}
$errors .= "</ul>
</div>";
}Het input veld:
<div class="contactform firstname" >
<label for="firstname"<?php if(isset($fout['text']['firstname'])) { echo 'class="fout"'; } ?>>Voornaam:*</label>
<input type="text" title="Vul uw firstname in." id="firstname" name="firstname" size="45" <?php if(isset($fout['input']['firstname'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($first_name)) { echo htmlspecialchars($first_name); } ?>" />
</div>En hoe de foutmeldingen worden weergegeven:
<?php
if(isset($errors)) {
echo $errors;
}
?>