Re: Re: Best way to test for form submission?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2009-08-28 at 09:33 -0700, Ben Dunlap wrote:
> I was surprised when no one recommended this:
> 
>    if ($_SERVER['REQUEST_METHOD'] == 'POST')
> 
> So now I'm wondering if there's a pitfall to this method that I'm not
> aware of...
> 
> Thanks,
> 
> Ben
> 

Well, as far as I'm aware $_SERVER isn't reliable from server to server.
That said, I've never had a problem using it.

I probably wouldn't use this however, as it does only check for the
existence of POST data. Sometimes I'll trigger the same PHP script from
both POST and GET. For example, a search form would use POST in the
initial form, and then if it was paginated, the links forwards and
backwards through the results would be GET (like Google) I usually just
tend to use the $_REQUEST array instead of $_POST or $_GET. You get the
benefit of being able to work with both arrays (as well as $_SESSION and
$_COOKIE) without any drawbacks.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux