[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6605
  • Last Modified:

Advantages/disadvantages of POST over GET

Hi can anybody give me a clear explanation as to why POST is more often chosen over GET in php?

Thanks.
0
Karl01
Asked:
Karl01
2 Solutions
 
cmc2006Commented:
The main differences are

GET
Uses the querystring to pass data - so data is visible in the address bar - not good for passwords etc!
Limit to the amount of data that is passed - The spec for URL length does not dictate a minimum or maximum URL length, but implementation varies by browser. On Windows: Opera supports ~4050 characters, IE 4.0+ supports exactly 2083 characters, Netscape 3 -> 4.78 support up to 8192 characters before causing errors on shut-down, and Netscape 6 supports ~2000 before causing errors on start-up.
 
Note that there is no limit on the number of parameters you can stuff into a URL, but only on the length it can aggregate to.

Browsers may reload a
GET URL automatically, particularly if cacheing is disabled (as is usually
the case with CGI output), but will typically prompt the user before
re-submitting a POST request.   This means you're far less likely to get
inadvertently-repeated entries from POST.

GET is (in theory) the preferred method for idempotent operations, such
as querying a database, though it matters little if you're using a form.
There is a further practical constraint that many systems have builtin
limits to the length of a GET request they can handle: when the total size
of a request (URL+params) approaches or exceeds 1Kb, you are well-advised
to use POST in any case.

GET can be bookmarked, and POST can't be.

in a nutshell:-

The Basic Difference

GET should be used if and only if there are no side effects.Many database searches have no visible side-effects and make ideal applications of query forms.The GET method is designed for getting information (a document, a chart, or the results from a database query).
POST method is designed for posting information (a credit card number, some new chart data, or information that is to be stored in a database).If the service associated with the processing of a form has side effects (for example, modification of a database or subscription to a service), the method should be POST.

Hope that makes sense!
0
 
Richard QuadlingSenior Software DeverloperCommented:
Just to confirm and agree with cmc2006.

Use a GET to GET data! Searches, pages, etc.

Use a POST to POST data! Logins, updates, etc.


0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now