Server side is the best way.
One way to do it is to have a check on the same page as the form, it can check the fields for valid data, if they are invalid, load the page showing the incorrect data and what needs to be fixed.
Sort of like:
if($action = "submit")
{
/ check the data
if it is fine then update the database or
whatever you need to do. then redirect them
somewhere
/
if(xxxxxx) / checking data /
{
/ it's fine redirect them /
header("Location:/somewhere");
}
else
{
/ create an error var and track what was not filled in /
/ do not redirect them, let the page load */
}
..... page info here .....
In the main part of the page, where the form is, add checks for the error var, if it exists you know something is wrong and you can show them what was missing.
example:
<? if($err == "firstname") print("You must supply your first name."); ?>
<input type="text" name="firstname" value="<? print($firstname); ?>">
Make any sense? It's not the most cohesive thing I've ever written here but it's a shot...and I'm tired! 🙂
-- Jason