View Full Version : Get stuff following the ?

07-05-2005, 10: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?

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

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


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


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?

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

07-06-2005, 02: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


so to get all of those just use

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

07-06-2005, 05: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.