Where can i get the script

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
User avatar
freshnet
php-forum Active User
php-forum Active User
Posts: 359
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Sat Oct 18, 2014 5:24 pm

If you want to track the referrer, the best way to do this is via a GET, e.g.

Code: Select all

www.urltovisit.com&referrer=1
www.urltovisit.com&referrer=2
www.urltovisit.com&referrer=3
If your username is unique, you could do something like hashing the username and using that as the referrer. md5 isn't the best option security-wise, but just an idea. You could also just use the user id of the referrer (hashed or not)

Code: Select all

$salt = 'Q2348Z*W!!'; //salt to add a bit more security 
$referrer = md5($username.$salt);

$link = 'www.urltovisit.com&referrer='.$referrer;

You can use php in the target page to get the referrer value and see how many people got there from that link. If you want to then credit the user, you'd have to go through all usernames and compare them to the hash:

Code: Select all

$key = $_GET['referrer'];
$salt = 'Q2348Z*W!!'; //salt to add a bit more security 

foreach ($row as $user_row)
{
$hash = md5($username.$salt);

if ($hash==$key)
{
//update the database or whatever with the credit for the referral
}
}

Post Reply