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.
Karl01Asked:
Who is Participating?
 
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 DeveloperCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.