Hi, i am trying to create an html form including select element and reading input from in listing 9.4, but it can not function. The problem is after i fill in the form, select the item in the form and click the button, it will link to the page listing9.5.php, but the listing9.5.php page show blank.
below are the codes:
listing9.4.php
<html>
<head>
<title>Listing 9.4 An HMTL form including a SELECT element</title>
</head>
<body>
<form action="listing9.5.php" method="POST">
Name: <br>
<input type="text" name="user">
<br>
Address: <br>
<textarea name="address" rows="5" cols="40"></textarea>
<br>
Pick Products: <br>
<select name="products[]" multiple>
<option>Sonic Srewdriver</option>
<option>Tricoder</option>
<option>ORAC AI</option>
<option>HAL 2000</option>
</select>
<br><br>
<input type="submit" value="hit it!">
</form>
</body>
</html>
listing9.5.php
<html>
<head>
<title>Listing 9.5 Reading input from the form in Listing 9.4</title>
</head>
<body>
<?php
print "Welcome <b>$POST['user']</b><p>\n\n";
print "Your address is:<p>\n\n<b>$POST['address']</b><p>\n\n";
print "Your product choices are:<p>\n\n";
if (!empty($POST['products'])) {
print "<ul>\n\n";
foreach ($POST['products'] as $value){
print "<li>$value\n";
}
print "</ul>";
}
?>
</body>
</html>
i already try to add ' ' for the array element, but still not working. So, anyone know the reason? Thanks in advance.