basic php question
<p>Sorry for the poor title, but as im not a experinced programmer i could think of a better one</p>

<p>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!</p>

<p>How would you suggest I do this?</p>

<p>Set a variable like, $wrongemail = 1;, $tooshortpass = 1; if wrong is wrong and then check in the form?</p>

<pre><code>if (!preg_match($regex, $email))  
$errors[] = "Invalid email address";

if (strlen($password) &lt; 4)
$errors[] = "Password too short";

// No errors?   
if (count($errors) == 0)
{
 // success
}

else
{
    foreach ($errors as $error)
    echo '&lt;li&gt;'.$error.'&lt;/li&gt;';
}



&lt;table cellspacing="5" cellpadding="0"&gt;

&lt;tr&gt;
&lt;td width="70px"&gt;Email:&lt;/td&gt;
&lt;td&gt;&lt;input type="text" name="email" class="textinput" /&gt;&lt;/td&gt;
&lt;td class="red"&gt;&lt;?php if error with email print here ?&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;Password:&lt;/td&gt;
&lt;td&gt;&lt;input type="text" name="password" class="textinput" /&gt;&lt;/td&gt;
&lt;td class="red"&gt;&lt;?php if error with password print here ?&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;input type="submit" /&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;/table&gt;
</code></pre>
