My approach has been to pass an "error code" back to the original form.
form.php: <?php print("<form aciton=\"formVerify.php\">"); print("a buncha form crap"); if ($errcode==1) print ("Your user id is wrong. You suck"); if ($errcode==2) print ("Your password is wrong. You really suck"); print("</form"); ?> Then in formVerify.php: <?php ...error checking code... if (userID invalid) header("Location: form.php?errcode=1"); if (password invalid) header("Location: form.php?errcode=2"); else header("Location: goodpage.php"); ?> You could probably also use cookies to pass the error code back and forth, but that's probably overkill and unreliable. (Sorry if the pseudo-code I used above offends anyone with the use of the word "suck"; the futile job search has got me really annoyed right now.) At 10:25 AM 12/4/2001, Mark Charette wrote: >I cheat and just include the original form on error ... > >Almost all my input values are set to PHP variables in the form. The 1st >time through none are set, so the values are blank. After submitting the >form, I check for validity. If there are errors I mark the errors, generate >an error string, and include the form. That way all previously typed in data >remains in the form without me having to tell the user to hit the "back" >button, and there's no horribly long URL string resetting all those values. > >There's a bit more work than that (using htmlspecialchars et al.) but if you >start creating forms with error checking & indication in mind it's really >easy to do validation and redisplay if necessary. > >Mark C. > > > > Hi, > > > > > > I wonder if someone could tell me whether or not the following is > > > possible? > > > > > > I have an HTML form which passes a username and password to a PHP script > > > for validation. If either is not valid, I would like it to return to the > > > previous page - carrying with it a variable plus the submitted form > > > information... > > > > > > =-=-=-=-=-=-=-=-= > > > if (strlen ($password1) <4 ) { > > > $err = "Password must be more than 4 characters long"; > > > header("Location:http://somelocation.php"); > > > // ^-- at the location, the $err and form variables will be available > > > > > > exit; > > > } > > > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: [EMAIL PROTECTED] "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]