Hey guys,
Can anyone tell me how I would validate a form with PHP without actually leaving the page?
Let's say I have a form that asks for "name", "email" and "message". lets say the user does not fill in their name but they fill out the "email" field and the "message " field. Right now I have a piece of code that looks like this:
if(strlen($name)<3)
{
$errormsg = "Please enter your full name";
header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/email.php?errormsg=".$errormsg);
exit;
}
It finds the div with the ID "errormsg" thought the GET function and displays the message, HOWEVER.........It resets the form. So if someone has typed in a short story they lose their entire message.....annoying!
So, how do I go about informing the user that they did not fill out a field correctly with out reloading the page or reseting the form?
Thanks in advance for your help.
JB