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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.