PDA

View Full Version : Preventing the Defining of Variables through urls


DrkFusion
01-03-2003, 03:00 AM
Sometimes I use some common variable names in my code, which is passed. How can I prevent that variable from being defined in the url for ex: http://www.domain.com/index.php?hits=1231231231232312
Or is it so that when the variable is already defined, it cannot be defined through url?

Thanks

Xenon
01-03-2003, 09:08 PM
in the first line of your script you can use unset($hits);

also if the varialbes are sent through a form, they will overwrite the urlvariables

DrkFusion
01-03-2003, 09:26 PM
Ah...so what is isset?

DrkFusion
01-03-2003, 09:28 PM
So for example, before the rest of the code starts I would put
unset ($hits);
then define it later?

also can you do this to multiple variables at once like?

unset ($hits, $visits, $rates);

Thanks

Xenon
01-03-2003, 09:31 PM
if you unset the var, you can redifine it later in the script without any problems :)

look into global.php there are a lot of unsets :)

i don't think you can unset more vars in one line...

NTLDR
01-03-2003, 09:42 PM
Originally posted by DrkFusion
Ah...so what is isset?

isset checks if a variable is set, ie has a value assigned to it:

eg:

$a = 1;
if (isset($a)) {
echo "a is set";
}

DrkFusion
01-04-2003, 03:20 AM
Ah thanks, I checked on php.net and unsetting multiple variables seems to be possible.

Thanks Guys!