Make referral links [closed]
I want to create and track referral links such as
www.domain.com/?ref=switz
How would I go about doing this?
The data will be in $_GET['ref']
. Track it however you like.
Create a database table of reference codes. Whenever someone wants to link to your site, create a new code in the database (probably with md5(uniqid())
), and generate the HTML link for them with that code in it , like <a href="http://example.com/?ref=cda4eee3898f8275ef78a733a47b1191">Go to Example.com!</a>
When a person visits your site via that link, the uniq code will be in the URL (in this case $_GET['ref']
), and you can read that and do whatever you want. To know who it was, just look up the code in the database.
From the example you've given, I assume www.domain.com is your website, and ?ref=switz is the referring website.
If so, you can get the value of ref using:
<?php
$ref = $_GET['ref'];
?>
精彩评论