Home >Backend Development >PHP Tutorial >PHP $_REQUEST
PHP $_REQUEST
PHP $_REQUEST is used to collect data submitted by HTML forms.
The example below shows a form with input fields and a submit button. When a user submits form data by clicking the submit button, the form data is sent to the script file specified in the action attribute of the ff9c23ada1bcecdd1a0fb5d5a0f18437 tag. In this example, we specify the file itself to handle the form data. If you need to use other PHP files to process form data, please change the file name to the file name of your choice. We can then use the super global variable $_REQUEST to collect the value of the input field:
Instance
<html> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> Name: <input type="text" name="fname"> <input type="submit"> </form> <?php $name = $_REQUEST['fname']; echo $name; ?> </body> </html>