On Thursday 10 January 2002 03:30, Chris Kwasneski wrote:

> I'm having a problem with a HTML form.  When it gets submitted, I keep
> getting an undefined variable error message.  And a blank page (aside from
> a 'Hi' written on it...).  I don't think its a problem with my install of
> PHP as other PHP code is running fine, but can't get it to print out this
> name.  I'm probably missing something simple, but I just can't figure it
> out.
>
> Any help would be appreciated.
>
> the form:
>
> <html>
>   <head>
>   <title>My Form</title>
>   </head>
>   <body>
>   <form action="test2.php" method="GET">
>
>   My name is:
>   <br> <input type="text" name="YourName">
>
>   <input type="submit" name="submit" value="Submit" />
>   </form>
>   </body>
>   </html>
>
>
> Test2.php file:
> <html>
> <head>
> <title>Form test...</title>
> </head>
> <body>
> Hi <?php echo "$YourName"; ?>
> </body>
> </html>
>
> The url that is getting passed to the file:
>
> http://localhost/test2.php?YourName=Chris&submit=Submit
>
> The error message I'm getting:
>
>
> [Wed Jan 09 14:24:47 2002] [error] [client 127.0.0.1] PHP
> Warning:  Undefined variable:  YourName in c:\program files\apache
> group\apache\htdocs\test2.php on line 10

You don't say what version of PHP you're using. If you're using the latest 
(4.1.1) and are using the recommended php.ini settings then things like GET, 
POST etc. are not automatically initialised into the variables space. So you 
would have to use something like:

  Hi <?php echo "$_GET[YourName]"; ?>

If you're not using php-4.1.1 then check php.ini and see whether 

  register_globals = On


hth
-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
Gee, Toto, I don't think we're in Kansas anymore.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to