views:

5047

answers:

9

Possible Duplicate:
When do you use POST and when do you use GET?

When should an HTML form tag use a GET method and when should it use a POST method?

+2  A: 

If you want the page to be bookmarked, such as a search result, then use GET. For sending any vaguely substantial amount of data, then POST is your best option.

A good rule of thumb is that unless you have a specific reason not to, then use POST.

nickf
A: 

POST is always a good idea if the request changes something.

stesch
+12  A: 

It is already answered here on stackoverflow.

rics
But I didn't find that question because it doesn't mention "html", "web-development", or even "http", only "https", and I don't have enough rights to edit it. :-)
rjmunro
Ok, then I have found it for you. :)
rics
I've added the html tag to the other post.
Bruce Alderman
+5  A: 

A GET method should only be used when the action will not make any changes to data on the server (except logging the page view), and will return broadly the same results, for example in a search response. The user can bookmark the results of a GET and revisit them regularly.

A post method should be used whenever anything will change on the server, and it does not make sense to bookmark the action itself. Also there is a limit to the amount of data that can be transferred in a GET request.

rjmunro
+2  A: 

According to the RFC "the GET method means retrieve whatever information [...] is identified by the Request-URI." So it's only meant to retrieve information and not change anything on the server.

Joachim Sauer
A: 

Use the POST consistently, because as the name implies, this HTTP method is meant to be for form posting while GET is for getting the information from the specified web resource.

Janko Mivšek
Nope. RFC 2616 (HTTP 1.1) is ignorant of HTML. If you just transfer semantics by similar names you skate on thin ice.
mkoeller
+6  A: 

Use POST to modify data.

Use GET to receive data.

Marcel
This is slightly incorrect: POST is cognate with insert/add/create, *PUT* is for update/modify. The fact that PUT is unsupported by forms is an awkward problem causing this POST abuse. In a RESTful world this matters though.
annakata
A: 

In HTML, one can specify two different submission methods for a form. The method is specified inside a FORM element, using the METHOD attribute. The difference between METHOD="GET" (the default) and METHOD="POST" is primarily defined in terms of form data encoding. The official recommendations say that "GET" should be used if and only if the form processing is idempotent, which typically means a pure query form. Generally it is advisable to do so. There are, however, problems related to long URLs and non-ASCII character repertoires which can make it necessary to use "POST" even for idempotent processing.

A: 

Basically GET method is for just web pages which contains static contents, or dynamic content with some user input. But POST method is to be used in certain situations like form filling, polls or similar inputs where duplications and multiple submissions can be problematic.

Further for enabling bookmarking better to go with GET method, keeping in mind that POST used pages let the browser to handle it with more care than POST.

Additionally for infomarion, GET is less safer than POST GET can deal with only ASCII where POST can deal with even binary

Pasan Indeewara