Re: Re: Best way to test for form submission?
| From: | Ashley Sheridan | Date: | Fri, 28 Aug 2009 15:32:00 +0000 |
| Subject: | Re: Re: Best way to test for form submission? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-297426@lists.php.net to get a copy of this message | ||
On Fri, 2009-08-28 at 11:29 -0400, tedd wrote:
> At 3:10 PM +0100 8/28/09, Stuart wrote:
> >2009/8/28 Eric <blueray2048@yahoo.com>:
> > > Here is another way
> >>
> >> if (isset($_POST['username']) && $_POST['username'] !=
> >> '')
> >> { ...
> >
> >If you use this method then you'll completely ignore a form submission
> >if they've forgotten to enter a username. Detection and validation are
> >two distinct steps and should be treated as such.
> >
> >-Stuart
>
>
> I usually treat forms this way:
>
> $action = isset($_POST['action']) ? $_POST['action'] : null;
>
> and then deal with $action.
>
> Dealing with $action means that I might clean/scrub it for storage in
> MySQL, or use it to determine a course of processing, or any number
> of other things.
>
> The point is to check IF a $_POST has occurred, without triggering an
> error if it hasn't, and to deal with the outcome either way.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com
> http://ancientstones.com ¼ß›#lTÉ[ßûi
> €http://earthstones.com
>
I have noticed a bug with using a form element named action, which
funnily enough only effects IE. If you need to do anything to or based
on that action element in IE with Javascript, it has a lot of problems
differentiating the form element from the form action attribute, and
gets them a bit confused. It's similar to the IE name/id bug.
Thanks,
Ash
http://www.ashleysheridan.co.uk