Please note, this is a STATIC archive of website technosmarter.com from 20 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
 

PHP: Request Method | Variable


What is the use of the Request method in PHP?

There is a simple use of the request method or request variable. You can say the $_REQUEST variable. The REQUEST variable can contain the contents of $ _GET, $ _POST, and $ _cookie.

In the previous tutorials, we discussed the GET method and the POST method in PHP. .We will discuss the cookie variable in another tutorial.

When we send the information using the POST method or GET method , we can get that information using the REQUEST variable. The REQUEST variable supports GET, POST, and cookie.

Definition of the REQUEST method

Request($_REQUEST) can access the value of the GET and POST method.

In PHP ,$_REQUEST is a superglobal variable that is used to collect the data after submitting HTML form .
The super global variable $_REQUEST contains the contents of $_GET, $_POST, and $_COOKIE.

Syntax

 

$_REQUEST['varibale_name'];

Example of the REQUEST method

In the below example, we create an HTML form. When a user fills the information and clicks on the submit button, the information contains by the REQUEST variable.

In the HTML form, we create two fields. In the HTML form, we use the GET method. The GET method encodes the information and sends it to the server. The encoded information separated by the? mark with the page.

We can use the REQUEST method to contains all information of the GET method. Let's create an example.

Example

<html>
<body>
<body>
<form action="" method="GET">
Name:

Email:


</form>
<?php
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
echo $name;
echo $name;
?>
</body>
</html>

In this above example, we have created two fields. Whatever information comes in both fields, the GET method handles that information of text boxes. With the help of the REQUEST variable, we have displayed the values of the GET method.

The $_REQUEST variable, you can use to get the result form data sent with both the GET and POST method.

Please Share

Recommended Posts:-