An HTML Form with a select Element : Form Select « Form « PHP






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>
  
  








Related examples in the same category

1.Form select input
2.An HTML Form Including a SELECT Element
3.A
4.A day choice
5.Validating a drop-down menu with in_array()
6.Displaying a
7.Generating a dynamic pull-down menu
8.Setting a default value in a
9.Setting defaults in a multi-valued
10.Creating Form Elements Based on the Current Time and/or Date
11.Creating Form Elements with Multiple Options
12.One choice for each day from 1 to 31
13.One choice for each year from last year to five years from now