Log in

View Full Version : Make Referral Link Travel With Visitor



OUT2WIN
01-05-2009, 07:14 AM
I have a referral program in place in my website.

The code assigned for users is http://www.example.com/?r=example

Or

To refer others, use <b><? example.com; echo $url; ?>http://www.example.com/?r=<? echo $row["username"]; ?></b>
<br>

Problems: It only goes to the index (home) page, When a visitor clicks on the register.php (register, sign-up) button it doesn't auto fill the referral option, it leaves it blank which kills the referral possibility.

If any other area of the site is explored, the referral link is closed (doesn't follow the visitor around the site) and like my problem above, it then is a blank input text area which will surely be left blank and will screw people out of their referrals.

The code above is used to assign users their referral link via the members.php area.

The following code is the one used for the register page (register.php):

Referrer (If Any):<br>
<input type="text" size="25" maxlength="15" name="referer" value="<? echo limpiare($_GET["r"]); ?>">

This script has had lots of errors in it (purchased) and I have been able to fix most of them, but I'm stuck after trying to fix this for weeks, I'm seeking help.

The menu.php file (all the clickable options: home, register, proof, scripts, ect..) is set up like this down the line of links:

<a href=\"index.php\">Home</a>

Thanks in advance, Please Help...
Rob

l_kris06
01-05-2009, 02:52 PM
I did not really understand the problem here, however i hope this helps.

you can get the referer page from using and use that further manipulations.



<?php
$referer = $_SERVER['HTTP_REFERER']; //returns the absolute url
$refererFile = basename($referer); //returns the filename. eg(index.php)
?>


Rgds,
Kris

OUT2WIN
01-05-2009, 07:49 PM
Thanks for the reply.

My problem is that the only time someone will get a referral actually sign up under them, is to have then put in the username of the person who referred them in the provided text area.

Each user is asigned a referral link (the same as 99% of most sites who do this) which is something like this:
http://www.example.com/?r=out2win

Then when they post it and a possible referral/visitor clicks on it, it should take them to the site, and travel along with them as they explore the site. Some sites have this feature so they can reap in referrals to sell and screw over members who are paying out of their pockets to advertise their site online. In my case, its just not routing correctly and I can't launch until this is fixed.

When someone clicks on the referral link it goes to the homepage:
http://www.example.com/?r=out2win, then if they click on any page including register it shows http://www.example.com/ with index.php or register.php and so on depending on what they click on. The referral part of the program gets lost or doesn't route correctly.

Everything credits correctly when your referrals click on ads and you make a protion. But unless a username is physically imputed, I will only harvest unreferred members who will then be placed into the "available for sale" referrals.

Thanks for the code, where would I place this so it will route? On the homepage correct? Where on the page?

Thanks again, I'm new at this.:D

JasonDFR
01-05-2009, 09:44 PM
Hi,

I don't think HTTP_REFERRER is what you are looking for.

I am understanding that you want to somehow make sure your r variable, in your example it would be out2win, sticks around and isn't lost when someone navigates away from the first page they come to on your site, where

www.example.com/?r=out2win

is in the user's browser's address bar.

If this is the case, then you need to use a $_SESSION['variable'] to keep track of the referrer.

So on any page that it is possible to have your referrer variable in the URL, you need to start a php session, session_start(); and then assign the r variable to a session variable like this:

$_SESSION['r'] = $_GET['r'];

Now the variable from the URL is stored as $_SESSION['r'] and you can use it anywhere on your site until the SESSION is destroyed or basically until the user leaves your website.

If you have some more specific questions, I'll do my best to help out.

Good luck,

JasonD

l_kris06
01-06-2009, 01:56 PM
Hi,

Ok, I am not sure if my understand is correct or not, however i figure that you want an URL stick with the GET parameters through out the redirection?

www.example.com/?r=out2win

Heres an example that i could think of ...hope it helps.

Filename: login.php


<?php
$user = "user";
$pass = "pass";
if($user == $pass){
$url = "main.php?user=".$user;
header('Location: '.$url);
exit;
}
?>

The above example will redirect you to a page(main.php) which is within the current directory and the url will also contain ur $_GET parameters.
You can use the above method to keep routing wherever u want with those $_GET parameters.

Method to retrieve $_GET in the redirected-to page.


<?php
$user = $_GET['user'];
echo $user;
?>