Get value from textarea in PHP
Description
The following code shows how to get value from textarea.
Example
<html>/*ww w. j ava 2 s . c o m*/
<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>
The following code is for index.php.
<html>/* w ww . java 2 s .c o m*/
<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>