|
Posted by BearItAll on 11/08/48 11:34
On Mon, 12 Dec 2005 15:21:21 +0000, SG wrote:
> Please bear with me as i'm new t ophp. In page 1 I ask for a variable in a
> form, like <input type=text name="lunch"> and the next file handes the
> variable.
>
> If I want to use the same variable in page3 or page 103, I think I have to
> use
> $_POST[$lunch]
>
> Is this right or do I have to use
> $_POST['$lunch'] or
> $_POST[lunch] or
> $_POST['lunch']
> Nothing I do seems to work.
>
> The same seems to be wrong when I use the $_REQUEST[] function.
These aren't functions, they arrays. You could look at them like this,
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
<input type='text' name='aname' />
<input type='text' name='age' />
<input type='submit' name='submit' />
<br><br><br>
<?php
if(isset($_POST['submit']))
{
foreach($_POST as $key => $value)
{
# $this->$key = $value;
echo "$key = $value<br>\n";
}
}
?>
</form>
If you enter "hello" and "45" it will output
aname = hello
age = 56
submit =
[Back to original message]
|