Re: Validating forms and showing errors
| From: | Manuel Lemos | Date: | Tue, 28 May 2002 15:48:18 +0000 |
| Subject: | Re: Validating forms and showing errors | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-99498@lists.php.net to get a copy of this message | ||
Hello,
On 05/27/2002 02:19 AM, Victor Boivie wrote:
Hi everybody, This might be a RTFM or STFW-question, but I haven't found it. I want to validate a form (in page1.php) to check if the user has entered a correct email-adress and more, and if he needs to correct some fields, I'd like to display the form again with all correct values filled in and the incorrect fields hightlighted.You may want to try this class that is meant precisely for that: http://www.phpclasses.org/formsgeneration
To make it a bit more difficult I've decided to POST to another file (post.php) which validates the information and redirects the user (with Header - Location) to page1.php if he has to correct the errors. If the form is correctly filled in then he will be redirected to page2.php. This is to prevent the browser for asking him if he wants to repost data if he hitsActually that does not prevent it. There are more robust way to prevent undesirable effects of form reposting. It depends what effects you want to avoid.
'Refresh'. Now I want to know how to pass information from post.php to page1.php since the form page (page1) needs to know what was incorrect and what was correct so that it can hightlight the bad fields. I don't want to stick it in the URL since it would be too ugly, but I do have session variables I can stick them in. Is this the way to go? Or is there a better solution?I would not bother to do that. I just make the script form generation, validation and processing be the same and your life will be much easier. -- Regards, Manuel Lemos