SERVER , GET, POST method in PHP

Total Post:113

Points:791
PHP
 323  View(s)
Ratings:
Rate this:

PHP $_SERVER?

PHP $_GET?

PHP $_POST?

  1. Post:140

    Points:984
    Re: SERVER , GET, POST method in PHP

    PHP $_REQUEST:

    <?php 
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // collect value of input field
        $name = $_REQUEST['fname'];
        if (empty($name)) {
            echo "Name is empty";
        } else {
            echo $name;
        }
    }
    ?>


    PHP $_GET: it is an array of variable which is passed current scipt link via URL.

    <html>
    <body>
    Welcome <?php echo $_POST["name"]; ?><br>
    Your email address is: <?php echo $_POST["email"]; ?>
    </body>
    </html>
    

    <?php 
    echo "Study " . $_GET['subject'] . " at " . $_GET['web'];
    ?>
    


    PHP $_POST : it is an array of variables which is passed current script link via HTTP.

    <html>
    <body>
    Welcome <?php echo $_GET["name"]; ?><br>
    Your email address is: <?php echo $_GET["email"]; ?>
    </body>
    </html>
    

    <?php
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // collect value of input field
        $name = $_POST['fname'];
        if (empty($name)) {
            echo "Name is empty";
        } else {
            echo $name;
        }
    }
    ?>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!