problem with form variables
| From: | Laura Silveira Mastella | Date: | Fri, 01 Feb 2002 13:57:37 +0000 |
| Subject: | problem with form variables | ||
| References: | 1 | Groups: | php.install |
| Request: | Send a blank email to php-install+get-5895@lists.php.net to get a copy of this message | ||
Well, now PHP is being parsed, but I have a problem with variables: they are
not being automatically set by PHP.
I have created a very simple html form (copied from php.net)
index.html
-----------------------------------------------
<form action="action.php" method="post">
Your name: <input type="text" name="name">
You age: <input type="text" name="age">
<input type="submit">
</form>
-----------------------------------------------
action.php
-----------------------------------------------
Hi <?php echo $name; ?>.
You are <?php echo $age; ?> years old.
-----------------------------------------------
The result is (error messages activated):
----------------------------------------------------------------------------
------------
Hi
"Warning: Undefined variable: name in c:\apache
group\apache\htdocs\action.php on line 1"
You are
"Warning: Undefined variable: age in c:\apache
group\apache\htdocs\action.php on line 2"
years old.
----------------------------------------------------------------------------
------------
I added <?php phpinfo(); ?> to action.php. The variables and their values
are there:
_POST["name"] Laura
_POST["age"] 21
but, they are not recognized inside the PHP code.
:(
Laura