$_request in php – $_POST, $_GET,$_POST, and $_REQUEST Examples

$_request in php : PHP $_REQUEST is a super global variable. Like as a PHP : $_REQUEST, $_POST, $_GET – PHP. The PHP $_REQUEST Variable is used to read the data from the submitted HTML form.

$_request in php

$_request in php will stay the same but the method in the form will change to you preference from GET or POST.

The $_REQUEST variable

<?php

echo "<pre>";
print_r($_REQUEST);
echo "</pre>";

?>

Syntax of $_REQUEST function

$_REQUEST[“element name”];

don’t Miss : jQuery ajax POST example

Example of PHP: $_REQUEST

It’s used to collect data after submitting html forms – Example of $_REQUEST function in PHP.
index.html

<html>
<head>
<title>Php contact form</title>
</head>
<body>
<form name="contact" method="post" action="do_action.php">
<table bgcolor=cornsilk style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0" align="center" >
<tr><td> </td><td>
 </td></tr>
<tr><td style="font-family: verdana; font-size: 10pt" align="right">
<b><font color=#CC0000>*</font><font color=#c60000> Member Name:</font></b></td><td>
<font color="#3d3d3d"><b><input size=25 name="member_name"></b></font></td></tr>
<tr><td style="font-family: verdana; font-size: 10pt" align="right"><b><font color=#CC0000>*</font><font color=#c60000> Primary Email:</font></b></td><td>
<font color="#3d3d3d"><b><input size=25 name="email_address"></b></font></td></tr>
<tr><td style="font-family: verdana; font-size: 10pt" align="right"><b><font color="#c60000">Location:</font></b></td><td align="right">
<font color="#3d3d3d"><b><input size=25 name="office_name" style="float: left"></b></font></td></tr>
<tr><td style="font-family: verdana; font-size: 10pt" align="right">
<b><font color="#c60000">Mobile No:</font></b></td><td>
<font color="#3d3d3d"><b><input size=25 name="mobile"></b></font></td></tr>
<tr><td colspan=2 style="font-family: verdana; font-size: 10pt">
<font color="#c60000"><b>        Comment</b></font><b><font color="#3d3d3d">:</font></b></td></tr>
<tr><td colspan=2 align=center><textarea name="comments" rows=6 cols=35></textarea></td></tr>
<tr><td colspan=2 align=center><input class="formbutton" type=submit name="send" value="Submit"></td></tr>
<tr><td colspan=2 align=center style="font-family: verdana; font-size: 10pt"><small>A <font color=red>*</font> indicates a field is required</small></td></tr>
</table>
</form>
</body>
</html>

do_action.php

<?php

echo "<pre>";
print_r($_REQUEST);
echo "</pre>";

$name=$_REQUEST['name'];
echo $name;
?>

don’t Miss :

Free Live Chat for Any Issue

Full Example – $_request in php

<?php
   if( $_REQUEST["member_name"] || $_REQUEST["member_age"] ) {
      echo "Welcome ". $_REQUEST['member_name']. "<br />";
      echo "You are ". $_REQUEST['member_age']. " years old.";
      exit();
   }
?>
<html>
   <body>
      
      <form action = "<?php $_PHP_SELF ?>" method = "POST">
         Name: <input type = "text" name = "member_name" />
         Age: <input type = "text" name = "member_age" />
         <input type = "submit" />
      </form>
      
   </body>
</html>

don’t Miss : jQuery ajax GET example with parameters

I hope you get an idea about $_request in php.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.