PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
For smaller things, like e.g. topic number or actual application mode it's quite easy and efficient to use GET. It's simpler to create link than hidden form field with some data that is POST'ed on_submit() . I think POST should be used only for large amounts of data like posts, articles, personal questionnaires, and some other things that user shouldn't see or shouldn't be cached in the browser history.
Since GET request query strings are incorporated directly into URLs, you should use the GET method whenever you want the user to be able to bookmark a page. For example, if you have made a search engine and you want your users to be able to bookmark results pages for quick access, you should use the GET method in your form and your search engine.
Draco_03 wrote:do you mean easyer to type OR faster to process ?
Easier to type But I think (of course I can be wrong ) it's also faster to process. The php doesn't have to read the POST data from the stdin, so one read process less, but it is only one process.
I generally assess the security risk at hand, then make a choice between POST and GET. I also take into consideration if I would like to display the information within the URL even if no security risk is present.
If it's a search engine...GET (?q=term)
If it's a login form...POST
If it's a template system..GET (?page=home)
If it's a email form...POST
etc, etc, etc.
In particular, the convention has been established that the GET and
HEAD methods SHOULD NOT have the significance of taking an action other than retrieval.
The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:
- Annotation of existing resources;
- Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles;
- Providing a block of data, such as the result of submitting a form, to a data-handling process;
- Extending a database through an append operation.