Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2005, 09:50 PM   PM User | #1
JoWiGo
Regular Coder

 
Join Date: Mar 2005
Posts: 114
Thanks: 4
Thanked 3 Times in 3 Posts
JoWiGo is an unknown quantity at this point
Get stuff following the ?

First of all, GREAT tutorials in the FAQ section. It really helped . 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...uff%20to%20buy) but I myself do not know how to get that information out. A simple question, I know. Any help?
JoWiGo is offline   Reply With Quote
Old 07-05-2005, 10:06 PM   PM User | #2
Anthony2oo4
Regular Coder

 
Join Date: Jul 2004
Posts: 201
Thanks: 8
Thanked 1 Time in 1 Post
Anthony2oo4 is an unknown quantity at this point
Ah, spmething I can help someone with

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:

PHP Code:
<?
$name 
$_GET['name'];
echo 
"$name";
?>
And that would output to the page help.

Any more info needed?
Anthony2oo4 is offline   Reply With Quote
Old 07-05-2005, 10:10 PM   PM User | #3
JoWiGo
Regular Coder

 
Join Date: Mar 2005
Posts: 114
Thanks: 4
Thanked 3 Times in 3 Posts
JoWiGo is an unknown quantity at this point
thanks, sites almost done . Never thought I coulda been doing this before, but hey it's working!
JoWiGo is offline   Reply With Quote
Old 07-06-2005, 01:45 AM   PM User | #4
Serex
Regular Coder

 
Join Date: Mar 2004
Location: Australia
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Serex is an unknown quantity at this point
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'];
Serex is offline   Reply With Quote
Old 07-06-2005, 04:26 AM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,659
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:57 PM.


Advertisement
Log in to turn off these ads.