Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I choose between GET and POST methods in HTML forms?

Tags:

I wish to know all the pros and cons about using these two methods. In particular the implications on web security.

Thanks.

like image 760
David Ameller Avatar asked Sep 21 '08 12:09

David Ameller


People also ask

What is the difference between GET and POST when using forms?

When the method is GET, all form data is encoded into the URL, appended to the action URL as query string parameters. With POST, form data appears within the message body of the HTTP request.

Why we use POST method instead of GET?

What difference does it make if you use POST versus GET requests in your applications? Here's just what you need to know. At a high level, when interacting with a Web server POST requests place user parameters in the body of the HTTP request. On the other hand, GET requests place such parameters in the URL.

Which method is more secure GET and POST method?

POST is more secure than GET for a couple of reasons. GET parameters are passed via URL. This means that parameters are stored in server logs, and browser history. When using GET, it makes it very easy to alter the data being submitted the the server as well, as it is right there in the address bar to play with.


1 Answers

To choose between them I use this simple rule:

GET for reads. (reading data and displaying it)

POST for anything that writes (i.e updating a database table, deleting an entry, etc.)

The other consideration is that GET is subjected to the maximum URI length and of course can't handle file uploads.

This page has a good summary.

like image 65
David McLaughlin Avatar answered Oct 19 '22 00:10

David McLaughlin