AdamDowning Posted June 7, 2010 Share Posted June 7, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/204052-how-would-i-go-about-this/ Share on other sites More sharing options...
Goldeneye Posted June 7, 2010 Share Posted June 7, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/204052-how-would-i-go-about-this/#findComment-1068786 Share on other sites More sharing options...
AdamDowning Posted June 7, 2010 Author Share Posted June 7, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/204052-how-would-i-go-about-this/#findComment-1068790 Share on other sites More sharing options...
cs.punk Posted June 7, 2010 Share Posted June 7, 2010 Why not automatically give them a username and password as simple as that? User: 5415 pass: zz5 But why not just use cookies? Quote Link to comment https://forums.phpfreaks.com/topic/204052-how-would-i-go-about-this/#findComment-1068878 Share on other sites More sharing options...
ignace Posted June 7, 2010 Share Posted June 7, 2010 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... Quote Link to comment https://forums.phpfreaks.com/topic/204052-how-would-i-go-about-this/#findComment-1068907 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.