Re: How to make a form retain its info
| From: | Brian T. Allen | Date: | Thu, 27 Jul 2000 19:27:59 +0000 |
| Subject: | Re: How to make a form retain its info | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8644@lists.php.net to get a copy of this message | ||
If you are looking for a skinny script, this approach isn't for you... :) I
sometimes have more lines of PHP than I do of HTML.
I pass a hidden variable when the form is submitted, this flag tells the
script to check for errors. So if you go to the form you see the empty
form, if you press submit, without inputing anything, you get a list of the
required fields missing info or with incorrect info (a 4 digit zip code, for
instance, or a letter in a phone number). Once the form is submitted
successfully you don't see the form, just a thank you page.
All of this takes place in the same page, looping back onto itself as many
times as necessary.
I don't have a template for it, as all of my forms vary in style and layout.
But it doesn't take long to create.
Brian
>
> >
> >The real solution to this is to design a form where they don't press the
> >back button if there is an error. All forms on all of my sites submit to
> >themselves, not another page, and display error messages in the page
itself,
> >with all of the information retained. Regardless of the browser or how
they
> >fill out the form, their information is retained until they are
successful
> >(unless they leave and come back of course).
>
>
> Interesting.. What do you trigger on to decide wether to "pre-load" the
form?
> Or do you check each field, and fill or not depending on wether something
> was there?
>
> I like the idea of flagging the errored field, but this script seems to be
> getting fat pretty quickly.
> You'd have to pass back something to point to the errored field(s)..
>
> Do you have a template for this?
>
> --
> www.SpamWhack.com A pre-emptive strike against spam
> Where's dave?
> http://www.findu.com/cgi-bin/find.cgi?kc6ete-9
>
> My transistor sings
> with unintended parasitic
> the smoke escapes
>
> By Jeff Stout