Forum Moderators: coopster

Message Too Old, No Replies

default value for get variable?

         

welkin

8:45 pm on Aug 9, 2005 (gmt 0)

10+ Year Member



basically i want to set a default value for this variable, which is to be replaced by the new GET variable the user submits, is there anyway to do that? it seems when i define a variable in the php script, it doesn't get replaced by the values i give via GET simulation (just adding?var=value) to the end of the url. any help would be greatly appreciated!

mcibor

8:55 pm on Aug 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if(!isset($_GET["variable"])) $var = "Default value";
else $var = $_GET["variable"];

Hope this helps
I didn't really understand the last part of your text.
Michal Cibor

welkin

9:11 pm on Aug 9, 2005 (gmt 0)

10+ Year Member



WOW. THANK YOU.

*sigh
I just heard of GET variables today so I was trying to see what it does... instead of assigning values correctly as you have shown ($a = $_GET["b"]), i set $a=$b (which somehow worked unless $a was set to some predefined value). v_v see all the problems that result when I don't learn this systematically...

Thanks again. =)

jatar_k

1:13 am on Aug 10, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



$a=$b

this will work if register_globals is on though we don't like doing that as it can cause all sorts of security issues

($a = $_GET["b"])

this is the correct way, we just ignore whether register_globals is on or off, it is always off by default now but some foolish hosts turn it on to be backward compatible

welkin

2:00 am on Aug 10, 2005 (gmt 0)

10+ Year Member



thanks jatar. there's soooo much i still need to learn. =P