·  PHP – Web Forms – Parameters – Multivalued form components


- Info:

  - PHP can treat multivalue form components as an array.

  - Name of such components shoulf have sufix '[]' like:



- Example:

  - Create PHP Web Application Test.php

  - http://localhost/Test.php

  - Select launch food and press Order

  - Following HTTP GET Request will be sent to server:




    <!-- DISPLAY FORM ------->

    <form action="Test.php" method="get">

      Order launch: <br/>

      <input type="checkbox" name="launch[]" value="soup"    />Soup   <br/>

      <input type="checkbox" name="launch[]" value="chicken" />Chicken<br/>

      <input type="checkbox" name="launch[]" value="coke"    />Coke   <br/>

      <input type="checkbox" name="launch[]" value="banana"  />Banana <br/>

      <input type="submit"   name="submit"   value="Order"   />



    <!-- DISPLAY FORM DATA -->


      if (isset($_REQUEST['submit'])) {

        echo "<b>You have ordered:</b><br/>";

        foreach($_REQUEST['launch'] as $launch) {

          $launch = htmlentities($launch);

          echo "$launch<br/>";