From what I can gather, there are three categories:
- Never use
GET
and usePOST
- Never use
POST
and useGET
- It doesn't matter which one you use.
Am I correct in assuming those three cases? If so, what are some examples from each case?
From what I can gather, there are three categories:
GET
and use POST
POST
and use GET
Am I correct in assuming those three cases? If so, what are some examples from each case?
1.3 Quick Checklist for Choosing HTTP
GET
orPOST
Use GET if:
Use POST if:
Source.
Read the article about HTTP in the Wikipedia. It will explain what the protocol is and what it does:
and
The W3C has a document named URIs, Addressability, and the use of HTTP GET and POST that explains when to use what. Citing
and
A practial example would be whenever you submit an HTML form. You specify either post or get for the form action. PHP will populate $_GET and $_POST accordingly.
From w3schools.com:
Here we distinguish the major differences:
Using it to update state - like a GET of
delete.php?id=5
to delete a page - is very risky. People found that out when Google's web accelerator started prefetching URLs on pages - it hit all the 'delete' links and wiped out peoples' data. Same thing can happen with search engine spiders.The original intent was that GET was used for getting data back and POST was to be anything. The rule of thumb that I use is that if I'm sending anything back to the server, I use POST. If I'm just calling an URL to get back data, I use GET.
Use GET when you want the URL to reflect the state of the page. This is useful for viewing dynamically generated pages, such as those seen here. A POST should be used in a form to submit data, like when I click the "Post Your Answer" button. It also produces a cleaner URL since it doesn't generate a parameter string after the path.