Saturday, February 26, 2011

DESPERATE- gettin checkbox values in POST (PHP)

 

  1. <html>
  2. <head>
  3. <title>checkbox help</title>
  4. </head>
  5. <?

  6. if (isset($HTTP_POST_VARS)) {

  7.     $fruit = $HTTP_POST_VARS["fruit"];

  8.     echo("Fruits chosen: " . count($fruit) . "<br><br>");

  9.     if (count($fruit)>0) {
  10.         echo("You chose the following fruits:<br>");
  11.     }

  12.     for ($i=0; $i<count($fruit); $i++) {
  13.         echo( ($i+1) . ") " . $fruit[$i] . "<br>");
  14.     }
  15. }
  16. ?>
  17. <body bgcolor="#ffffff">

  18. <form method="post">
  19. Choose a fruit:<br><br>
  20. <input type="checkbox" name="fruit[]" value="apples">apples <br>
  21. <input type="checkbox" name="fruit[]" value="oranges">oranges <br>
  22. <input type="checkbox" name="fruit[]" value="peaches">peaches <br>
  23. <input type="checkbox" name="fruit[]" value="mangos">mangos<br>
  24. <input type="submit">
  25. </form>

  26. </body>
  27. <html>

No comments:

Post a Comment

add this