+ 1
What is the difference between get and post?
hello, I just wanna know what is the difference between get and post and when shoud I use each one of them. If you know the answee then please explain it in an easy way.^_^ thanks previously.
3 Answers
+ 7
GET and POST methods differs in the way used to send data (commonly from forms) to the server, by appending textual key/values pairs at URL (named a 'query string'), or inside the Http header (as well as cookies, which are availabled by this way at server side).
Example of Get request Url:
http://mydomain.com/mysite/mypage.html?key1=val1&key2=val2
It's considered unsafe in first case (GET, data in URL), as data are visible from anybody, and mainly:
> by browsers possibility it can be:
- be cached
- remain in the browser history
- be bookmarked
> just by user copying-pasting it can be:
- distributed & shared
- simply hacked
Contrarly, in a Post method, the data is no more visible directly by an human in the Url, but is embeded in the Http header, wich is a data-set of information initiating a communication between an internet browser on a user PC through the web protocol Http to server and reciprocally (they handle for example the Http error messages when the request fail in server-browser response way, or the user agent information about browsers in browser-server way).
With AJAX, wich use Http requests too (without reloading/replacing the actual page), Get method has no more really 'unsafe' problems, as the most inconvenients disapears (not cached nor reamining in history, not bookmarkabled nor simply hackabled)
Anyway, by Post method, data are unsafe exchanged while you don't use Https crypted version of protocol ^^
With common Http uncrypted, you need to consider Post method less unsafe than Get, rather than more safe :P
+ 18
"When you use GET, the form data will be visible in the page address.
Use POST if the form is updating data, or includes sensitive information (passwords).
POST offers better security because the submitted data is not visible in the page address."
Source: HTML Course -> HTML Basics -> Forms
+ 1
thanks