Re: How to make a form retain its info
| From: | Jonatan Bagge | Date: | Fri, 28 Jul 2000 09:36:53 +0000 |
| Subject: | Re: How to make a form retain its info | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8749@lists.php.net to get a copy of this message | ||
Your'e right i guess.
And if it's not a multipage-form you might even wan't to put the db stuff
on that page to....
/ Jonatan Bagge
"Boget, Chris" wrote:
> > An even better way is to output a new form on the second page
> > where all the data is already filled in (using the variables that
> > was sent) And maybe a little red star or something to point out
> > what was filled in incorrectly.
> > So that they can change it and submit it again..
>
> Except that why should a subsequent page have to know anything
> about the preceeding page? The answer is that it shouldn't and in
> doing this, you are just doubling the amount of code you have (the
> initial code on the first page and then the same code on the second
> page in case the use has an error).
>
> I like to make all form pages as modular as possible and as such,
> they only know about and process their own form elements. When
> the form is submitted, it comes back to itself (form action=$PHP_SELF)
> to validate the element values and insert/update the database as
> needed. If everything is all good, the user is directed to the next
> page (along with any necessary variables as GET) otherwise the
> code drops down to redisplay the form along with the values that
> were entered by the user. On a slight tangent, Jay Bloodworth's
> FormClass is an invaluable tool when working with Forms and is
> highly useful in a situation like this as it has a mechanic built in
> to validate your form elements so you don't have to.
>
> Bearing the above in mind, 99% of all my form pages look some-
> thing like this:
>
> ------------
>
> <CUT>...