PHP – $_GET/$_POST Methods

Forms are the most commonly used to send and received enquiries on any website. So there are two methods which are mainly used to send information from browser client to the server.

The $_Get Method in PHP :

When we use $_GET method in any form, the browser will append all the form values in the page page URL as a query string. All the form values will be added after the (?) character and if there is any space in the fields values and browser will automatically will replace the space + sign and pass all the values on the form action page. You can see this using the following example:

Example:

The $_POST method in PHP

$_POST is another most important method to pass the form values to the server. In this method, all information is sent using the HTTP headers.

Example:

Difference between $_GET and $_POST methods

  • In $_GET method, all form values are sent as a query string instead in $_POST all values are sent using HTTP headers.
  • $_GET method has some limit (upto 1024 characters) in passing the form values instead $_POST method doesn’t have any restriction in variable passing.
  • $_GET method is not much secure because all values are sent as query string instead $_POST method is highly secured method.
  • $_GET method can be used to send binary data like images etc. instead $_POST can send all kind of data in a very secured way.

 

 

Leave a Reply

Your email address will not be published.