the user is asked to enter some names (just for this example) and they can enter as many as they like.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>';
}
?>
Example....
Input - Paul Gina Emma John
Output....
But...Hi Paul Gina Emma John
What I want is the following...
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!!Hi Paul
Hi Gina
Hi Emma
Hi John
Hoping someone can spot the mistake here and can help me to fix this.
Thanks in advance.
Smithster.



Reply With Quote

Bookmarks