Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GET vs. POST (form processing)

Tags:

post

forms

get

I completely understand the differences between the two in terms of form handling, user discretion and privacy of data, but in what situation would anyone rather use GET over POST when sending form results?

Thanks

like image 846
benhowdle89 Avatar asked Jan 12 '11 12:01

benhowdle89


3 Answers

W3C HTML 4.01 Recommendation on the appropriate usage of GET and POST:

The "get" method should be used when the form is idempotent (i.e., causes no side-effects). Many database searches have no visible side-effects and make ideal applications for the "get" method.

If the service associated with the processing of a form causes side effects (for example, if the form modifies a database or subscription to a service), the "post" method should be used.

Note: The "get" method restricts form data set values to ASCII characters. Only the "post" method (with enctype="multipart/form-data") is specified to cover the entire [ISO10646] character set.

like image 180
Flying Swissman Avatar answered Oct 11 '22 17:10

Flying Swissman


GET places parameters in the URL itself, allowing everyone to see. While POST would be ideal for logins and security-sensitive data, GET is ideal when you want a dynamic page to be bookmarked.

Take a forum for example. The thread which shows all posts within it is loaded dynamically. There doesn't exist a page for every thread available, meaning parameters must be provided which indicate which thread to load. These parameters are passed using GET so that you can bookmark the page and that exact URL with the parameters provided will be used again to load the page.

like image 7
Neil Avatar answered Oct 11 '22 17:10

Neil


For instance, to make form data visible in logs.

like image 2
Dennis Kreminsky Avatar answered Oct 11 '22 17:10

Dennis Kreminsky