View Full Version : Pulling information from a url

04-15-2004, 05:38 AM
I need help.
I'm going crazy trying to figure this out.
Here is what I am trying to do.

Page 1- http://www.test.com/test.php?id=username
I need to store the username in a cookie.

Page 2- http://www.test.com/form.php
I will have a hidden text box that needs to have the value of the cookie.
It is so I can keep track of referrals.

Example: user1 refers someone to my site. The id "user1" gets stored in a cookie. The visitor browses many pages on my site. If the visitor go to the sign-up form page, then a hidden text box will hold the value stored in the cookie, which should be "user1". This way when the information is sent, I can credit user1 for the referral.

This is what I have been trying:

On Page 1 http://www.test.com/test.php?id=user1
<? setcookie("refer","$_GET['id']",time()+36000); ?>

On Sign-up form page
<input type="hidden" name="referrer" value="<? echo $HTTP_COOKIE_VARS["refer"]; ?>">

I hope I don't confuse anyone. It's hard to explain.

04-15-2004, 09:02 AM
Welcome here !

<? setcookie("refer","$_GET['id']",time()+36000); ?>

should be

<? setcookie('refer',$_GET['id'],time()+36000); ?>

and best change

<input type="hidden" name="referrer" value="<? echo $HTTP_COOKIE_VARS["refer"]; ?>">


<input type="hidden" name="referrer" value="<? echo $_COOKIE['refer']; ?>">

04-15-2004, 02:46 PM
Thank you so much. It works perfectly.

I'm actually very surprised that I wasn't too far off on my own.

Oh well, Thanks again.

04-15-2004, 03:54 PM
You're welcome !

Sometimes these little things make the difference ... Glad you got it running now :thumbsup: