Page 1 of 1

Passing variables thru a URL

Posted: Sat Jun 15, 2002 11:08 am
by Jim
http://members.lycos.co.uk/jibfyb/

Select an item in the dropdown menu and you will see the URL change to "http://members.lycos.co.uk/jibfyb/index ... eryouchose".

Now, in that textarea box (which currently says '<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>'...) I have this code:

if($map == cat){ print("Hah!"); } else { print("<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>!"); }

So, choose cat in the dropdown menu.

The textarea box STILL says '<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>'.

How do I make sure $map is seen throughout the page as whatever has been selected in the drop box?

Thanks!

Re: Passing variables thru a URL

Posted: Sat Jun 15, 2002 12:30 pm
by amnuts
Okay, this looks like your problem. You don't pass a query string like that. You need to start the query string with '?', and then just have the name of the variable (no $ sign.) Such as:

http://members.lycos.co.uk/jibfyb/index.php?map=cat

If you have global variables turned on you can then access it with $map in the script (once submitted), or with $_GET/$_POST, depending on the method of your form.

If you want more than one vairable you'd serperate up the variable/data pair with &, such as:

index.php?map=cat&name=scratch&colour=tan

Andy

Posted: Mon Jun 17, 2002 4:03 am
by mikeq
and don't put " around the variable value

http://www.me.com/page.php?map=themapyouwant

Posted: Mon Jun 17, 2002 4:09 am
by twigletmac
To access the map variable with register_globals turned off you'd use,

Code: Select all

$_GET&#1111;'map']
Mac