Discussion:
Notice: Undefined variable:
Richard West
2002-10-25 03:01:05 UTC
Permalink
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??

Richard West
***@hotmail.com
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thoenen, Peter Mr. EPS
2002-10-25 02:27:38 UTC
Permalink
RTFM would fix this in 2 minutes but trying to avoid work.

First off, make that <form><div>....</div></form> ... <form> is not a block
element and you can't place <input>'s in it ... eg <form><input/></form> ...
you can but its a) illegal b) bad form. But I digress. All your form
variables are in the enviromental arrays $_POST and $_GET .... try <?php
echo $_GET['guest_name']?>

-Peter
-----Original Message-----
Sent: Friday, October 25, 2002 05:01
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??
Richard West
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Hornig at NOSPAM artshock2d dot de
2002-10-25 06:50:47 UTC
Permalink
Post by Richard West
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??
Richard West
ahm, which version of php you're using?

from version 4.2.3 the get and post requests changed because of a security
problem. now you have to access the post and get variables with
$HTTP_GET_VARS[] or
the short $_GET[] or for post variables $HTTP_POST_VARS[] or the same in
short $_POST[].

i think that would be the problem...

an other advice could be: go into your php.ini and set "register_globals"
on. ... but it isn't recommend...

i hope i could help you!? :)
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
neil smith
2002-10-25 08:44:31 UTC
Permalink
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.
Date: Thu, 24 Oct 2002 22:01:05 -0500
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??
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Continue reading on narkive:
Loading...