X

Rate Us :



Share with Friends :

Menu

Concept of GET & POST :

GET :

  • GET transfers the information through http head location & displays the data on URL address.

  • GET is unsecured.

  • GET transfers limited amount of data.

  • GET can't upload the file.

POST :

  • POST transfers the information through document body.

  • POST is highly secured.

  • POST transfers huge amount of data.

  • POST can upload the files.

$_GET :

By using $_GET we can get the posted values of GET method. It is an array variable having total number of elements equals to the total number of posted values.


$_POST :

It is used to get the posted value of POST method.

Example :

<form method = "GET" action = "Page1.php"> <input type = "text" name = 't1'> <br> <input type = "text" name = 't2'> <br> <input type = "submit" name = 'sub' value = 'click'> </form>

<?php echo $_GET['sub']; ?>

Output :


$_REQUEST :

By using this super global variable we can get the posted values of get method and post method. We can also get the values of cookies and query string.


Query String :

It is a small amount of data on URL address followed by "?". If we want to transfer some extra data along with the form data we can use it. We can pass query string in two ways :-

  • query string with name and value.

  • query string with only value.

By using $_request we can read the query string which contains name & value.

Example :

<form method = "POST" action = "Page1.php? n = 100 & uname = Man"> <input type = "text" name = 't1' value = "Enter Name"> <br> <input type = "submit" name = 'sub' value = 'click'> </form>

<?php if(isset($_REQUEST['sub'])) { echo $_REQUEST['t1']; echo $_REQUEST['n']; echo $_REQUEST['uname']; } ?>

Output :