Re: Notice: Undefined variable:
| From: | neil smith | Date: | Fri, 25 Oct 2002 08:44:31 +0000 |
| Subject: | Re: Notice: Undefined variable: | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-16545@lists.php.net to get a copy of this message | ||
Yeah sure - there is a setting called 'register_globals' which is available to acquire variables from post or get vars but its off by default for security reasons. You can set this to On in php.ini file
The better way though is to explicitly state where you want to acquire user iinput : in your case it would be
$HTTP_GET_VARS['guest_name'] or $_GET['guest_name'] depending on the version of PHP you run. Form values sent using POST rather than GET are exactly the same, use $HTTP_POST_VARS or $_POST to access the array of variables. GET and POST variables are arrays. Theres also $HTTP_POST_FILES[] which is populated when you use a file upload field in your form.
You will need to read the manual more for posting files, there are a few gotchas.
Good luck
Neil Smith.
At 02:14 25/10/2002 +0000, you wrote:
Message-ID: <20021025015917.6473.qmail@pb1.pair.com> To: php-windows@lists.php.net Reply-To: "Richard West" <ice_dog76@hotmail.com> From: "Richard West" <ice_dog76@hotmail.com> Date: Thu, 24 Oct 2002 22:01:05 -0500 Subject: Notice: Undefined variable: Hey, I just installed apache and php on my desktop and everything was working great. I went to go make a form and I am getting these errors everytime I try to access one of the variables in the form Notice: Undefined variable: guest_name in C:\www\book_add.php on line 18 anyone got an idea why its doing it. this is what my form looks like. <form method=get action="book_add.php"> Your Name: <input name="guest_name" type="text"><br> Your e-mail: <input name="address" type="text"><br> Your comments:<br> <TextArea name="comments" cols="50" rows="5"> </textarea> <br> <br> <input type=submit> </form> and my out put it this <?php $guest_name; ?> any ideas why I can't access my query variables??