Mega Code Archive

 
Categories / Php / Form
 

An HTML Form with a select Element

<html> <head> <title>An HTML Form with a 'select' Element</title> </head> <body> <div> <form action="index.php" method="post"> <p><input type="text" name="user" /></p> <p><textarea name="address" rows="5" cols="40">  </textarea></p> <p><select name="products[]" multiple="multiple">   <option>A</option>   <option>B</option>   <option>C</option>   <option>D</option> </select></p> <p><input type="submit" value="hit it!" /></p> </form> </div> </body> </html> //Reading Input from the Form <html> <head> <title>Reading Input from the Form</title> </head> <body> <div>  <?php   print "Welcome <b>" . $_POST ['user'] . "</b><br/>";   print "Your address is:<br/><b>" . $_POST ['address'] . "</b><br/>\n";      if (is_array ( $_POST ['products'] )) {     print "<p>Your product choices are:</p>";     print "<ul>";     foreach ( $_POST ['products'] as $value ) {       print "<li>$value</li>\n";     }     print "</ul>";   }   ?>  </div> </body> </html>