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.
Differences in form submission
For both METHOD="GET"
and METHOD="POST"
, the processing of a user’s submit request (such as clicking on a submit button) in a browser begins with a construction of the form data set, which is then encoded in a manner which depends on the ENCTYPE
attribute. That attribute has two possible values mentioned in the specifications, but multipart/form-data
is for "POST"
submissions only, whereas application/x-www-form-urlencoded
(the default) can be used both for "POST"
and for "GET"
.
Then the form data set is transmitted as follows (quotation from the HTML 4.0 specification):
- If the
method
is"get"
– -, the user agent takes the value ofaction
, appends a?
to it, then appends the form data set, encoded using theapplication/x-www-form-urlencoded
content type. The user agent then traverses the link to this URI. In this scenario, form data are restricted to ASCII codes.- If the
method
is"post"
–, the user agent conducts an HTTPpost
transaction using the value of theaction
attribute and a message created according to the content type specified by theenctype
attribute.