What is the Difference Between get , post and request method ?

21 Dec

In HTML to transfer records from one page to another page , attribute method is used in form tag.

i.e :

<form method="post" action="action.php">
data goes here .......
</form>

Now , In this case action.php is destination page where user will have records .

in PHP : there are 3 methods to retrieve data from receiving page.

1 ) $_GET

2) $_POST

3) R_REQUEST

$_GET :

$_GET is a super global array which is an inbuilt array. Which collects values from a form sent with method=”get” as well it collects values from URL also. ( e.g. http://www.domainname.com/pagename.php?data=123)

You can print $_GET with inbuilt function in php i.e ( print_r($_GET) ).

IMP : Information sent from this method will be visible in ( address bar of any browser ) and has limitation on characters .

As per W3C Community limitation can be extended up to 4000 characters

Myth: Search services will not index anything with a “?” in the URI.
Myth: URIs cannot be longer than 256 characters
for details : visit : About $_GET limitation :

You can read more details about $_GET.

$_POST :

$_POST is a super global array which is an inbuilt array. Which collects values from a form sent with method=”post”.

You can print $_GET with inbuilt function in php i.e ( print_r($_POST)  ).

IMP : Information received from POST method is always invisible in ( address bar of any browser ) . It has more limit on sending characters to action page.

This limitation can be set in php.ini file

Note: We can change by setting the POST_MAX_SIZE in the php.ini file . by default we will find this value with 8MB in most of the php.ini file.

$_REQUEST :

$_REQUEST is a super global array which is an inbuilt array. Which collects values from a form sent with  either method=”post” or method=”get” .

You can print $_REQUEST with inbuilt function in php i.e ( print_r($_REQUEST)  ).

IMP : One of the best way of getting data on action page , here we did not require to check that which method we have used to pass data from sending page.Even $_REQUEST get records from the COOKIE also.

Leave a comment