RE: [PHP] form submission error trapping

From: Date: Mon, 18 Feb 2002 00:02:46 +0000
Subject: RE: [PHP] form submission error trapping
Groups: php.general 
Request: Send a blank email to php-general+get-85134@lists.php.net to get a copy of this message
sure - $error could be an array, so the code I supplied could be changed to: if you're email client supports rich text, then the changed lines are in green <? // filename: here.html if ($submit) { $error = array(); if (trim($email) == "") { $error["email"] = true; } // process more... if (count($error) == 0) { // do stuff here, maybe a header("location:...."); exit; } } ?> <html> <form action="here.html" method="post"> <? if ($error["email"]) echo "Error: please fill in your email address"; ?> <input type="text" name="email" value="<?= $email; ?>"> <input type="submit" name="submit" value="Go For It!!!"> </form> </html> -----Original Message----- From: Jason Dulberg [mailto:jdulberg@sympatico.ca] Sent: Monday, February 18, 2002 10:40 AM To: Martin Towell Cc: php-general@lists.php.net Subject: RE: [PHP] form submission error trapping Thanks for the code.... Is there a way to keep track of what fields had the errors as its possible for people to have like 5 errors? Thanks again. Jason -----Original Message----- From: Martin Towell [mailto:martin.towell@world.net] Sent: February 17, 2002 6:41 PM To: 'jdulberg@sympatico.ca'; Steven Walker Cc: php-general@lists.php.net Subject: RE: [PHP] form submission error trapping something like: <? // filename: here.html if ($submit) { $error = false; if (trim($email) == "") { $error = true; } // process more... if (!$error) { // do stuff here, maybe a header("location:...."); exit; } } ?> <html> <form action="here.html" method="post"> <input type="text" name="email" value="<?= $email; ?>"> <input type="submit" name="submit" value="Go For It!!!"> </form> </html> not tested but should work - just expand on it Martin -----Original Message----- From: Jason Dulberg [ <mailto:jdulberg@sympatico.ca> mailto:jdulberg@sympatico.ca] Sent: Monday, February 18, 2002 10:22 AM To: Steven Walker Cc: php-general@lists.php.net Subject: RE: [PHP] form submission error trapping Ya, it would be cool if you could.... how do you submit the form to itself? Right now, I have something like if (!$submit) { display form } else { process if (trim($email)=="") { echo "error, hit back button to fix"; } } Thanks Jason > -----Original Message----- > From: Steven Walker [ <mailto:steve@walkereffects.com> mailto:steve@walkereffects.com] > Sent: February 17, 2002 6:18 PM > To: jdulberg@sympatico.ca > Cc: php-general@lists.php.net > Subject: Re: [PHP] form submission error trapping > > > Jason, > > I just finished one of my form pages, and I'm really happy with how it > turned out. > > I created one php page that both displays the form and validates the > input. When the user hits the submit button, it submits the data to > itself. If anything is missing from the page, the form is reshown with > missing fields highlighted and the other fields filled in. If on the > other hand the info passes the validation test, the information is shown > to screen a new button (hidden form) allows the user to continue. > > If you want, I can send you a link to my test site so you can check it > out. > > Steven J. Walker > Walker Effects > www.walkereffects.com > steve@walkereffects.com > > On Sunday, February 17, 2002, at 02:22 PM, Jason Dulberg wrote: > > > I am working on some error trapping for several forms on my site. After > > visiting a bunch of websites, I've noticed 2 common methods of > > displaying > > error messages. > > > > 1. display an error box on a new page and force the user to hit the > > <back> > > button > > > > 2. display the form again with appropriate error text and pre-filled > > fields. > > > > I have part of the error on the new page working but I'm running into > > the > > infamous no contents in the form after going <back>. > > > > There are some useability issues with forcing the user to hit the back > > button -- some just don't want to bother. > > > > Is there a way to display the form w/original contents and error > > messages > > 'without' having to code the entire form twice? I have about 5 forms > > with 50 > > fields or so each. > > > > What would be the best way to go about redrawing the form with the > > errors > > shown beside each field? > > > > Any suggestions are greatly appreciated. > > > > __________________ > > Jason Dulberg > > Extreme MTB > > <http://extreme.nas.net> > > http://extreme.nas.net > > > > > > -- > > PHP General Mailing List ( <http://www.php.net/> > > http://www.php.net/) > > To unsubscribe, visit: > > <http://www.php.net/unsub.php> http://www.php.net/unsub.php > > > > > -- PHP General Mailing List ( <http://www.php.net/> http://www.php.net/) To unsubscribe, visit: <http://www.php.net/unsub.php> http://www.php.net/unsub.php

« previous php.general (#85134) next »