How to differentiate between POST and GET?

How to differentiate between POST and GET?

am 16.01.2008 16:20:48 von martin

Is there a simple way to tell if a page was submitted as a POST or a
GET?

I have a page that contains a form with multiple submit buttons. If
the page is POSTed, I go through a somewhat complex analysis of what
needs to be done depending on which button was clicked.

On the other hand, if the page was submitted via GET, I simply set
some default values and send it out. I'd like to be able to do this
without having to look for every button only to find out that none
were submitted.

Re: How to differentiate between POST and GET?

am 16.01.2008 16:44:20 von kimandre

Martin wrote:

> Is there a simple way to tell if a page was submitted as a POST or a
> GET?
>
> I have a page that contains a form with multiple submit buttons. If
> the page is POSTed, I go through a somewhat complex analysis of what
> needs to be done depending on which button was clicked.
>
> On the other hand, if the page was submitted via GET, I simply set
> some default values and send it out. I'd like to be able to do this
> without having to look for every button only to find out that none
> were submitted.

You could try checking the value of $_SERVER["REQUEST_METHOD"].

--
Kim André Akerø
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)

Re: How to differentiate between POST and GET?

am 16.01.2008 16:51:15 von martin

On 16 Jan 2008 15:44:20 GMT, Kim André Akerø
wrote:

>Martin wrote:
>
>> Is there a simple way to tell if a page was submitted as a POST or a
>> GET?
>>
>> I have a page that contains a form with multiple submit buttons. If
>> the page is POSTed, I go through a somewhat complex analysis of what
>> needs to be done depending on which button was clicked.
>>
>> On the other hand, if the page was submitted via GET, I simply set
>> some default values and send it out. I'd like to be able to do this
>> without having to look for every button only to find out that none
>> were submitted.
>
>You could try checking the value of $_SERVER["REQUEST_METHOD"].

Perfect! Thank you.

Re: How to differentiate between POST and GET?

am 17.01.2008 12:52:19 von Toby A Inkster

Martin wrote:
> Kim André Akerø wrote:
>
>>You could try checking the value of $_SERVER["REQUEST_METHOD"].
>
> Perfect! Thank you.

Note that "POST" and "GET" are not the only possible values it can take.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 17 days, 23:04.]

Gnocchi all'Amatriciana al Forno
http://tobyinkster.co.uk/blog/2008/01/15/gnocchi-allamatrici ana/