...

View Full Version : Get stuff following the ?



JoWiGo
07-05-2005, 09:50 PM
First of all, GREAT tutorials in the FAQ section. It really helped :thumbsup:. But now I need to know one last thing.

How can I pass along variables in the url? I know I have seen it done (http://www.site.com?user=Josh&age=42&search=stuff%20to%20buy) but I myself do not know how to get that information out. A simple question, I know. Any help?

Anthony2oo4
07-05-2005, 10:06 PM
Ah, spmething I can help someone with :D

Serex and SeeITSolutions helped me with this a couple days ago. see here:

http://www.codingforums.com/showthread.php?t=62202

Its easy really, if you where to have your url like so:

yourdomain.com?name=help

then in ur php page you would have:


<?
$name = $_GET['name'];
echo "$name";
?>

And that would output to the page help.

Any more info needed?

JoWiGo
07-05-2005, 10:10 PM
thanks, sites almost done :D. Never thought I coulda been doing this before, but hey it's working!

Serex
07-06-2005, 01:45 AM
As anthony mentioned you can use $_GET['varname'] to 'get' any values passed through the URL. just remember after the first ? you need to use &. i.e

page.php?name=john&age=17&sex=male

so to get all of those just use

$name = $_GET['name'];
$age = $_GET['age'];
$sex = $_GET['sex'];

Fou-Lu
07-06-2005, 04:26 AM
If your careful, you can also use an extract() function combined with the QUERY_STRING in order to retreive all of your variables in one shot. The key word is if you are careful. Doing this method without any type of control allows a client to specify whatever variables they would like to use, not just the ones you would like to use.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum