Breaking

LightBlog

Saturday 4 July 2015

PHP Request Array


$_REQUEST is an Array which is used for store $_GET,$_POST, $_COOKIE etc in PHP script.  By this function we can use data which is send by $_GET, $_POST in PHP Programming. In this programming if we don’t know which method is using for sending data? Then we can use $_REQUEST method for better solve this problem. $_REQUEST is a Global array which used for collection information from HTML form by using PHP Script. The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
                                                
PHP Request Array
We can say that $_REQUEST is combination Array of $_GET, $_POST or $_COOKIE. If we have using $_GET or $_POST method then we can access data by $_REQUEST in PHP Programming.

Example 1:


<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
Username:<input name="username" type="text" />
Password:<input name="pass" type="text" />
<input name="submit" type="submit" value="Submit" />
</form>
<?php
if($_POST['submit'])
{
foreach($_REQUEST as $key=>$val)
{
echo $val."<BR>";
}
}
else
{
?>
<?php
}
?>
</body>
</html>


Example 2:

<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
Username:<input name="username" type="text" />
Password:<input name="pass" type="password" />
<input name="submit" type="submit" value="Submit" />
</form>
<?php
echo $_REQUEST['username']."<Br>";
echo $_REQUEST['pass'];
?>
</body>
</html>

Here Video Tutorial

                                      
Adbox