Hii @kartik,
The $_REQUEST variable is used to read the data from the submitted HTML form.
Sample code:
Here, the $_REQUEST variable is used to read the submitted form field with the name ‘username’. If the form is submitted without any value, then it will print as “Name is empty”, otherwise it will print the submitted value.
<?php
if (isset($_POST['submit'])) {
// collect value of input field
$name = $_REQUEST['username'];
if (empty($name)) {
echo "Name is empty";
} else {
echo $name;
}
}
else
{
?>
<form method="post" action="#">
Name: <input type="text" name="username">
<input type="submit" name="submit">
</form>
<?php } ?>
Hope this is helpful
Thank you! |