Sorry for the poor title, but as im not a experinced programmer i could think of a better one
Instead of storing errors in arrays, then show a list of errors in some of my forms i would like to show them next to the input field. Its so sexy!
How would you suggest I do this?
Set a variable like, $wrongemail = 1;, $tooshortpass = 1; if wrong is wrong and then check in the form?
if (!preg_match($regex, $email))
$errors[] = "Invalid email address";
if (strlen($password) < 4)
$errors[] = "Password too short";
// No errors?
if (count($errors) == 0)
{
// success
}
else
{
foreach ($errors as $error)
echo '<li>'.$error.'</li>';
}
<table cellspacing="5" cellpadding="0">
<tr>
<td width="70px">Email:</td>
<td><input type="text" name="email" class="textinput" /></td>
<td class="red"><?php if error with email print here ?></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" name="password" class="textinput" /></td>
<td class="red"><?php if error with password print here ?></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" /></td>
</tr>
</table>