More than one input to a form question - how to process?
PHP Code:
<?php
if(isset($_POST['submit'])){
$names = array($_POST['names']);
foreach($names as $value)
{
echo 'Hi '.$value.' <br />';
}
}
else
{
echo '<form method = "POST" action = "">';
echo '<p>Names</p>';
echo '<p><textarea rows="10" name="names" cols="37"></textarea></p>';
echo '<p><input type="submit" value="Submit" name="submit"></p>';
echo '</form>';
}
?>
the user is asked to enter some names (just for this example) and they can enter as many as they like.
Example....
Input - Paul Gina Emma John
Output....
Quote:
Hi Paul Gina Emma John
But...
What I want is the following...
Quote:
Hi Paul
Hi Gina
Hi Emma
Hi John
I have a perfectly good reason for wanting to know how to do this. I don't often post real scripts anymore as I found myself just relying on others to fix the script and then I wouldn't learn anything. So I think up an example to use which needs fixing and then I learn from that!!
Hoping someone can spot the mistake here and can help me to fix this.
Thanks in advance.
Smithster.