PHP表单处理

I have a html form which has 2 textbox and a text area. I am fetching the data from the form using a php code to display it on another page.

html form code:

    <html>

<form name="addsg" method="POST" action="validate.php">

<div class="label">name</div>
<div class="response"><span><textarea class="textarea" name="name"></textarea></span></div>


<div class="label">age</div>
<div class="response"><span><input class="textbox" name="age" type="text" size="5" maxlength="5" value="" /></span></div>


<div class="label">place</div>
<div class="response"><span><input class="textbox" name="place" type="text" value="" /></span></div>

<div class="submit_section button">
<input id="generate" type="submit"  name="script" value="generate" />
</div>

</form>
</html>

PHP code:

<?php

    if (!empty($_POST['name']) 
    && !empty($_POST['age'])
    && !empty($_POST['place']))

   {
 echo '<textarea name="textarea" id="textarea" cols="100" rows="5" readonly>';

      echo "{$_POST['name']},{$_POST['age']} years old, from {$_POST['place']}";
     echo '</textarea>';
   }
 ?>

If I put only one name in name text area column, I will get output like this

anoop,26 years old, from IN

But if I put more than one name in the name column(with same age and place), output showing like this

anoop
Tom,26 years old, from IN

Age and place are showing only for one name, not for all. I would like to get output like this

 anoop,26 years old, from IN
 Tom,26 years old, from IN

any suggestions ?

<?
$name_array = explode( "
", $_POST['name'] ); //use the new line char as the separator
?>

<textarea name="textarea" id="textarea" cols="100" rows="5" readonly>
<?
foreach( $name as $name_array )
  echo $name.', '.$_POST['age'].' years old, from '.$_POST['age']."<br/>
";
?>
</textarea>

You can put multiple textbox for name and declare name as array .

for example:

<input type="text" name="ex[]" id="ex"/>
<input type="text" name="ex[]" id="ex1"/>

PHP:

for($1=0;$i<count($_POST['ex']);$i++){

echo $_POST['ex'][$i];

}

Try this, that should work out.

<?
$lines = array();
$names = explode("
", $_POST['name']);

foreach($names as $name)
  $lines[] = $name.', '.$_POST['age'].' years old, from '.$_POST['age'];
?>

<html>
<body>
<textarea name="textarea" id="textarea" cols="100" rows="5" readonly>
<?php implode("
", $lines); ?>
</textarea>
</body>
</html>

try to use these two function with order : 1- nl2br($_POST['name']) 2- strip_tags()

maybe some hidden html tags is causing that