473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to differentiate between POST and GET?

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.
Jan 16 '08 #1
3 1208
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ø
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Jan 16 '08 #2
On 16 Jan 2008 15:44:20 GMT, Kim André Akerø
<ki******@NOSPAMbetadome.comwrote:
>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.
Jan 16 '08 #3
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/0...llamatriciana/
Jan 17 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
0
by: Chung Leong | last post by:
Q. How do I differentiate an empty string or numeric zero from false? A. Use the === operator.
1
by: Suresh | last post by:
Hi all, Here is my code, if(event.which) keycode = event.which;//For Mozilla else keycode = event.keyCode;//For IE But my problem is, the value of keycode returns 46 for pressing...
5
by: mayur_hirpara | last post by:
Hi, I have been developing web applications for a while now. However, as I was thinking through the architecture I really don't understand the "How server can identify between which buttons has...
2
by: adam | last post by:
Hi ASP Expert, I encounter a page reload situation in ASP. It is I need a way to differentiate whether the current page - "Application_Result.asp" got reloaded itself when user click on the...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
3
by: mayur_hirpara | last post by:
Hi, I am writing a VB.NET application. It is a Windows application at the moment. The application contains a button. the click event of button perform a long running task. It needs to be started...
2
by: Hans-Joerg Unger | last post by:
Hi ! How can I differentiate nodes in an xml-schema which have the same name (see "file"-element in the example) , but different locations and meanings in the xml tree: How can i...
1
by: josephChiaWY | last post by:
Hi all, I am a newbie in php. I have met a problem in echoing a few submit buttons using while loop. How do i differentiate which submit button is being click in order to grab the correct data....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.