Saturday, December 7

Difference Between GET and POST

My previous post explains how to send mail using the inbuilt php mail() command by retrieving the contents of the form using the GET and POST methods. We get the data from the user in both the ways, then why are there two different methods, what exactly is the difference between the two methods.

Both the GET and the POST method do the same work but the difference is in the way the work is performed. It has some limitations and some advantages.
We will take the GET method first. This method collects the data from the fields and send them in the address bar by using the ?, & and = signs. The address bar after form submission looks something like this
http://www.somedomain.com/sendmail.php?name=somename&
email=somename%40somedomain.com&message=somemessage&button=Submit

Using this method has some disadvantages.
  • You can send only a limited content using this method. (As you can clearly see the address bar) Too long typed message will give out an error message.
  • You cannot send files using this method.
  • Any user can read the content submitted previously using the history stored in the browser. (The address bar shows it all)

In other means this method it useful only if there is a small amount of the data and that too is not confidential.

On the other hand the POST method is much useful.
The data send through the POST method is sent via html headers and so is not visible to others. Its main advantages can be listed as :
  • Data submitted is invisible.
  • Large amount of the data can be sent. (8 MB size limit by default, but can be changed through php.ini in post_max_size)
  • Can send files attachment.
  • Can be very useful for user authentication purposes.
These are the major differences that I found out in both the GET and POST methods, there might be many more. See if you can find out more.

No comments:

Post a Comment

Comment anything you want. Just be polite and give respect to others!
I am simply going to remove the comments which are offensive or are off topic.
And please don't spam your website links in comments. I don't, neither should you.