Jump to content

How would I go about this?


AdamDowning

Recommended Posts

Hey guys

 

Im not very advanced at PHP scripting, but I kinda need a script that would most likely rely on PHP and mySQL. I need a script, that when a user visits the site, they are automatically assigned a referral URL, without registration. Now, when they send this referral URL to friends, and their friends visit it, it adds one to the count of the amount of people they have referred to the site. Nobody has to register here however, just visit.

 

The point of this you may ask, is that when a user visits the website, and then refers 'x' friends, they will unlock more content of that website, be it a new tutorial, or something along those lines. I would be greatly appreciative if someone could assist, or even write a script that could do this. I have already looked at scripts such as:

 

http://www.bigresource.com/Tracker/Track-php-blnqZCmf/

 

But I wouldn't be 100% sure how to add a referral URL, and so a new one is generated for every person in the format of something like http://www.mysite.com/index.php?ref=12345

 

Thanks for your help.

AdamDowning

Link to comment
Share on other sites

Well, without registration, you really only have a person's Internet Protocol Address to rely on. And that is not a very reliable way to identify a user especially since a lot of your guests might have Dynamic IP addresses meaning their IP Address will change regularly.

 

One thing you could do is if users wish to come back to your site, give them an option to "download" or "save" a unique-Identification number which you assign to them as a file and then have them upload that file (per session) as they return to the site. It's might not be what you had in mind but it also isn't registration or forcing users to provide their e-mail address.

Link to comment
Share on other sites

Hey guys.

 

I figured this out. But when I put it on my server, it doesn't write anything to ips.txt, even when its created, and nor does it display/add to a referral count, nor does it display a referral url.

 

<?php
function get_Referrals()
{
  $code = $_SERVER['REMOTE_ADDR'];
  $code = md5($code);

   if(file_exists($code . '.txt'))
    {
     $referrals = file_get_contents($code . '.txt');
    }
   else
    {
     $referrals = 0;
    }
}

  $ips = file_get_contents('ips.txt');
  $ips = explode(',',$ips);

if(in_array($_SERVER['REMOTE_ADDR'],$ips))
  {
   if(isset($_GET['refcode']))
    {
     $file = fopen($code . '.txt','w');
     fwrite($file,'0');
     fclose($file);
     $refs = file_get_contents($_GET['refcode'] . '.txt');
     $refs++;
     $file = fopen($_GET['refcode'] . '.txt','w');
     fwrite($file,$refs);
     fclose($file);
     $file = fopen('ips.txt','w');
     fwrite($file,$_SERVER['REMOTE_ADDR'] . ',');
     fclose($file);
    }
   else
    {
     $file = fopen('ips.txt','w');
     fwrite($file,$_SERVER['REMOTE_ADDR'] . ',');
     fclose($file);
    }
  }
else
  {
  }
?>
<html>
<head>
<title>Free Microsoft Points</title>
</head>
<body>
Your Refs: <b><?php echo $referrals; ?></b><br />
<?php
if($referrals<5)
{
echo 'Text BEFORE Referral Amount';
}
else
{
echo 'Text AFTER Referral Amount';
}
?>
<br /><br />
Your Referral Link: <input type="text" size="60" value="http://share-cash.net/index.php?refcode=<? echo $code; ?>" />

 

Any help please?

Link to comment
Share on other sites

Generate a unique referral link for each visitor. When someone visits your website with a referral link then add 1 to the referral link together with their IP-address (although this is a pretty weak security against referral link spamming).

 

Then whoever referred it to their friends can use the referral link to see how many he has referred (visible to everyone). But like cs.punk already told you it's best to use a username/password, it solves really many problems you will otherwise face. To give an example referral identity theft? Multiple people claim to be the owner of a certain referral link...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.