Re: [PHP] Re: Checking for form submission

2004-08-04 Thread Jason Wong
On Wednesday 04 August 2004 18:21, Craig Donnelly wrote:
> Ok, in simple form - If the submit button was clicked,
> If some one hits enter this would be a problem, easy way to resolve
> this would be to have a hidden form element flagged and to terst for that
> instead of the
> submit button, wouldnt you agree Jason?

I would simply check whether $_POST is empty(), if it isn't, assume form 
submitted then do further tests/processing.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
He who is good for making excuses is seldom good for anything else.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Checking for form submission

2004-08-04 Thread Craig Donnelly
Ok, in simple form - If the submit button was clicked,
If some one hits enter this would be a problem, easy way to resolve
this would be to have a hidden form element flagged and to terst for that
instead of the
submit button, wouldnt you agree Jason?

Craig

"Jason Wong" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Wednesday 04 August 2004 17:34, Craig Donnelly wrote:
>
> > If you want to test to see if a form has been submitted, I would suggest
> > that you
> > use the name from the submit button.
> >
> > e.g - 
> >
> > if(isset($_POST['sendform'])){
> > echo "Form has been submitted!";
> > }
> >
> > So basically this checks if the form button "sendform" is set.
>
> This is not reliable, some browsers does not set the submit button if it
was
> not explicitly clicked on. Even some big name free webmail providers fall
> into this trap of just checking for the submit button rather than checking
> the form as a whole.
>
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> --
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> --
> /*
> The biggest difference between time and space is that you can't reuse
time.
> -- Merrick Furst
> */

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Checking for form submission

2004-08-04 Thread Jason Wong
On Wednesday 04 August 2004 17:34, Craig Donnelly wrote:

> If you want to test to see if a form has been submitted, I would suggest
> that you
> use the name from the submit button.
>
> e.g - 
>
> if(isset($_POST['sendform'])){
> echo "Form has been submitted!";
> }
>
> So basically this checks if the form button "sendform" is set.

This is not reliable, some browsers does not set the submit button if it was 
not explicitly clicked on. Even some big name free webmail providers fall 
into this trap of just checking for the submit button rather than checking 
the form as a whole.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The biggest difference between time and space is that you can't reuse time.
-- Merrick Furst
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Checking for form submission

2004-08-04 Thread Craig Donnelly
Hi Shaun,

Your  expression is evaluating, if you like does the $_POST superglobal
exist and it does
but might be empty, this would be the same for $_GET and other superglobals.

If you did the following:

if (isset($_POST) && !empty($_POST)) {
   echo '(isset($_POST))';
}

This would only appear if there was in fact a $_POST variable 'set'.

If you want to test to see if a form has been submitted, I would suggest
that you
use the name from the submit button.

e.g - 

if(isset($_POST['sendform'])){
echo "Form has been submitted!";
}

So basically this checks if the form button "sendform" is set.

HTH,

Craig

"Shaun" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I am trying to create some code to check whether a form has been
submitted.
> The following code seems to print evertime, whether a form has been
> submitted or not:
>
> if (isset($_POST)) {
>   echo '(isset($_POST))';
>  }
>
> This seems most odd, could someone tell me why this happens?
>
> Thanks for your help.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php