• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

placing and retrieving parameters in URL's via PHP

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Burning Phoenix

Member
Joined
Jul 3, 2001
Location
Schenectady NY
how do you place PHP parameters into url's?
How do you then use PHP to retreive this information from the url?
Is there a simple one liner to do this and be able to take out multiple parameters/ variables?
 
I think you'd be better of passing the params like
something.php:
Code:
<HTML><HEAD><TITLE>php parameters page</TITLE></HEAD><BODY>
<A HREF="http://www.abc.com/somthing.php?p1=abc & p2=123">param test</A><P> <!--please remove spaces in URL-->
resuls:<BR>
param1 <?=$p1?><BR>
param2 <?=$p2?><BR>

</BODY></HTML>
[code]

I didn't test the page, but that should display a link and then and the values of param1 and param2 if they were passed in.

in the url, the querystring starts right after the ? and parameters are seperated by & and parameters can be sent as name=value pairs

PHP will create a variable for each of the name=value pairs, so you don't have to do anything to get the data from the querystring.

edit: slight rewrite to fix bug in display...
 
Last edited:
Ok i didn't think it was this easy but a close example of an url i'm thinking of would be like this:
www phoenixhideout com/overclockers/seti/counter.php?email=jim@phoenixhideout com

Now assuming i'm right in my counter.php script i can assume that this is correct:
$email = jim@phoenixhideout com
 
There's 3 main ways to send/recieve data from one script to the next. GET, POST and Sessions.

GET can be used in 2 ways. Through a form with the method="GET" or directly into the query string like you were doing above. All of the data is held in the array $_GET

POST can only be used through a form. The data is invisible to the user. You use the $_POST array for that data.

And of course the almighty sessions. Sessions provide a way to keep a user logged in. When a session is started it checks if there is a session in progress, if so php will retrieve the ID from a file it's held in. If not it creates a new one. Sessions are passed with the $_SESSION array. The forums for example use sessions to keep you logged in. If you look at the query string once your logged in, you'll see s=, this tells php a session is in progress and it should retrieve the ID. You can also pass this through a cookie. That keeps a user logged in even if he closes the browser. Without the cookie, the session will be deleted if the user closes the browser.

if you want more help, there's always the official php manual, http://www.php.net/manual/en and another great site http://www.devshed.com has excellent tutorials on php
 
Ok i didn't think it was this easy but a close example of an url i'm thinking of would be like this:
www phoenixhideout com/overclockers/seti/counter.php?email=jim@phoenixhideout com

Now assuming i'm right in my counter.php script i can assume that this is correct:
$email = jim@phoenixhideout com

Short answer: Yes

When you pass a ? parameter in this way PHP automatically creates the variable for you.
 
Back