·  PHP – Syntax – Variables – Scope – Superglobal – $_POST

 

- Info:

  - $_POST superglobal array contains information parameters passed using the POST method.

  - You cannot reference POST variables like this: $email, $pswd, and $subscribe.

 

- Example:

  - Create PHP Console Application Test.php.

 

    Test.html

    <form action="subscribe.php" method="post">

      <p>

        Email address:<br />

        <input type="text" name="email" size="20" maxlength="50" value="" />

      </p>

      <p>

        Password:<br />

        <input type="password" name="pswd" size="20" maxlength="15" value="" />

      </p>

      <p>

        <input type="submit" name="subscribe" value="subscribe!" />

      </p>

    </form>

 

    Test.php

    <?php

   

      //SOME VARIABLES FROM _GET.

      $_POST['email'    ] = "jason@example.com";

      $_POST['pswd'     ] = "rainyday";

      $_POST['subscribe'] = "subscribe!";

        

      //LIST ALL VARIABLES FROM SUPERGLOBAL ARRAY _GET.

      foreach ($_POST as $var => $value) {

         echo "$var => $value \n";

      }

        

    ?>