PHP $_REQUEST superglobal

PHP $_REQUEST
  • PHP $_REQUEST is a PHP super global variable which is used to collect data after submitting an HTML form.
  • example


  • <?php
    if( $_GET["fname"] || $_GET["lname"] ) {
    echo "Your first name is ". $_GET['fname']. "<br>";
    echo "Your second name is ". $_GET['lname'];
    exit();
    }
    ?>
    <html>
    <body>
    <form action = "<?php $_PHP_SELF ?>" method = "GET">
    First Name: <input type = "text" name = "fname" />
    Last Name: <input type = "text" name = "lname" />
    <input type = "submit" />
    </form>
    </body>
    </html>

    Output:

    Your first name is ram
    Your second name is sharma