When To Use Http Post Or Get Methods In Html Forms

  • Published: July 25, 2016


HTTP request methods are defined in RFC2616 Section 9 Method Definitions. These methods are also known as verbs as they indicate the desired action to be performed on an identified resource.

Understanding the basics in simple terms

From a practical point of view, these are the most simple (not so accurate) definitions and differences.

GET method

$_GET is an array of variables passed to the current script via the URL parameters.


POST method

$_POST is an array of variables passed to the current script via the HTTP POST method.

POST /data/form HTTP/1.1
Host: example.com

When to use GET vs POST methods

In most cases:

GET should be used to __retrieve data__ from a specified resource and sending __non-sensitive__ data.
POST is the preferred way for sending __form data__.
Can be __cached__
Remain in the __browser history__
Can be __bookmarked__
Data visible in URL
Used with __sensitive data__
__Data length__ restrictions
ASCII data type allowed
Binary data type allowed
Content-Type application/x-www-form-urlencoded
Content-Type multipart/form-data


A search page should use GET, while a form that changes your password should use POST.


Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.
comments powered by Disqus

What's the difference between HTTP GET and POST methods? When to use methods GET and POST in HTML forms.

Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 ·