...

View Full Version : form validation problem - urgent plz help



gaurav_sting
04-16-2004, 11:51 AM
hi,

i have been trying to implement the form validation, in which the user is shown error in RED (or any) color next to the textbox or any input box in the next page, if he or she does not enter or enters wrong information.

I am trying to implement the validation similar to what happens when a user registers for an account for Yahoo Mail. He/she is shown the only fields which are left out or inputted wrong.

NOTE: i am using smarty templating system.

Plz help me finding a code snippet or some tutorial.

Thanx
Gaurav

miranda
04-16-2004, 10:51 PM
something similar to this?


submit.html


<form method=post action=input.php>
<table>
<tr>
<td>Name <input type=text name="name" ></td>
<td></td>
</tr>
<tr>
<td>Email <input type=text name="Email"></td>
<td></td>
</tr>
<tr>
<td colspan=2> <input type=submit value="submit"></td>
</tr>
</table>
</form>



input.php


<?php
$name = $_POST['name'];
$email = $_POST['email'];
if(!$name) || (!$email){
echo "<form method=post action=input.php>\n";
echo "<table>\n\t<tr>\n";
if(!$name){
echo "\t\t<td>Name <input type=text name=\"name\" ></td>\n";
echo "\t\t<td><font color=red>Missing Name</font>";
echo "<input type=hidden name=\"email\" value=\"".$email."\"></td>\n\t<tr>\n";
}
if(!$email){
echo "\t\t<td>Email <input type=text name=\"email\" ></td>\n";
echo "\t\t<td><font color=red>Missing Email</font>";
echo "<input type=hidden name=\"name\" value=\"".$name."\"></td>\n\t<tr>\n";
}
echo "\t<tr>\n\t\t<td colspan=2>";
echo "<input type=submit value=\"submit\"></td>\n";
echo "\t</tr>\n</table>\n</form>";
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum