|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Undefined variables from POST
Hello.
I'm very new to PHP and am having trouble with my first form. I've tried a very simple HTML page that captures the user's name and age and then POSTs them to a PHP page that welcomes the user by reporting their name and age. The error I'm getting is that the variables are not defined. I'm working on a Windows XP desktop, coding in PHP 5 running from an Apache 2 server. The code for the HTML page is: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Get user info...</title> </head> <body> <h1>Who are you??</h1> <hr> <form action="simplewelcome.php" method="post"> <p>Your name: <input type="text" name="name" /></p> <p>Your age: <input type="text" name="age" /></p> <p><input type="submit" /></p> </form> <hr> </body> </html> ...and the code for the PHP page is... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Get user info...</title> </head> <body> <h1>Welcome!</h1> <hr> Hi <?php echo $_POST['name']; ?>! You are <?php echo $_POST['age']; ?> years old. <hr> </body> </html> You'll probably recognize that these are taken straight from the PHP manual, so I have no idea of what's going wrong. Thanks in advance for the help! |
|
#2
|
|||
|
|||
|
RE: Undefined variables from POST
the script you posted works form me but i have php 4.2.3
|
|
#3
|
|||
|
|||
|
RE: Undefined variables from POST
In your form attribute, i removed the:
action="simplewelcome.php" Then, it works fine. what does the "simplewelcome.php" file do? |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Undefined variables from POST |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|