PDA

View Full Version : Undefined variableS


Bluemonkey
07-18-2003, 12:53 PM
how can i stop getting this error:

Notice: Undefined variable: Action in E:\Dev\php_bits\todo\todo.php on line 111

the variable is going to be coming from the query string so when the user clikc son new , delete or update... so on "todo.php?Action=New"

at the monet the code is

if ($Action == "new") {

code

}

but i get the error on $Action.


any help??


Cheers

raf
07-18-2003, 01:07 PM
probably cause register_globals is set to off (in your php.ini file) . So you need

if ($_GET['Action'] == "new") {

code

}

Bluemonkey
07-18-2003, 01:12 PM
is it really that much of a risk to have register_globals on?

Bluemonkey
07-18-2003, 03:38 PM
i fixed it i found the "isset" thing

so now i have

if (isset($_GET['Action'])) {
if ($_GET['Action'] == "new") {
code
}
}

raf
07-18-2003, 05:51 PM
is it really that much of a risk to have register_globals on?
Yes.

http://be2.php.net/manual/en/printwn/security.registerglobals.php

But working with values from the querystring without doing proper checks is still unsecure, even if register_globals = off.
In your case, the only valid value is "new" so that's quite restrictive, but if you append user-input to the querystring, you need to run some addition check.

What the added value of the isset here?