Php program to execute the request and post method

A Php program to execute the request and post method. In this program we can execute the request and post program in php. $_REQUEST is a global variable in PHP that is used to collect data after an HTML form has been submitted. The example below shows a form with an input field and a submit button. When a user submits form data by clicking “Submit,” the data is transferred to the file specified in the form> tag’s action element.

<html>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Name: <input type="text" name="fname">
<input type="Execute">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$name = $_REQUEST['fname'];
if (empty($name))
{
echo "File is empty";
}
else
{
echo $name;
}
}
?>

</body>
</html>

 

Output:

Name: