Advantages/disadvantages of POST over GET

Posted on 2006-04-26
Last Modified: 2013-12-12
Hi can anybody give me a clear explanation as to why POST is more often chosen over GET in php?

Question by:Karl01

    Accepted Solution

    The main differences are

    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!
    LVL 40

    Assisted Solution

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now