V Posted August 13, 2010 Share Posted August 13, 2010 I'm working on a web project where I need to generate something similar to affiliate links. For example, someone signs up and he/she gets a unique link (http://www.site.com/6372) and later I can display data according to the user's unique affiliate link. I can't find any good info about this.. Does anyone know how affiliate programs work in general? Quote Link to comment https://forums.phpfreaks.com/topic/210595-simple-affiliate-programs-how-do-they-work/ Share on other sites More sharing options...
sbaker Posted August 13, 2010 Share Posted August 13, 2010 If you want to generate a random, unique link, you can use a sufficiently complicated randomizer (You can use microtime() to get a random number, then run that through some hash algorithm, like md5().) and append the code to the end of a link with their e-mail address. Send that to their e-mail address, check the code at the end of the URL with $_GET and compare the code to what's stored in your DB for that username at the time the code was generated. If that's not what you're asking about, can you be more specific? Quote Link to comment https://forums.phpfreaks.com/topic/210595-simple-affiliate-programs-how-do-they-work/#findComment-1098683 Share on other sites More sharing options...
Alex Posted August 13, 2010 Share Posted August 13, 2010 The link provided in your example (http://www.site.com/6372) would be made using mod_rewrite. It might be mapped to something like http://www.site.com/?referral_id=6372. Then the page would have some code like this: if(isset($_GET['referral_id'])) { // create a cookie on the user's computer to store the ID of who referred them } Then when registering you'd check to see if they have the referral cookie set. If they do and it's a valid code then add a successful referral to the user whose referral id is in the cookie. Quote Link to comment https://forums.phpfreaks.com/topic/210595-simple-affiliate-programs-how-do-they-work/#findComment-1098685 Share on other sites More sharing options...
V Posted August 15, 2010 Author Share Posted August 15, 2010 @sbaker thanks, your info was very helpful that's what I was asking for. @AlexWD I haven't thought of using cookies, I'll give that a try thanks! One thing I forgot to ask is, how do I know which referral link someone clicked on? Like if someone clicks on http://www.site.com/6372 from another site, how would I retrieve the referral link to use in my site? Quote Link to comment https://forums.phpfreaks.com/topic/210595-simple-affiliate-programs-how-do-they-work/#findComment-1099510 Share on other sites More sharing options...
V Posted August 15, 2010 Author Share Posted August 15, 2010 One thing I forgot to ask is, how do I know which referral link someone clicked on? Like if someone clicks on http://www.site.com/6372 from another site, how would I retrieve the referral link to use in my site? Wow.. I need to drink my morning coffee.... Quote Link to comment https://forums.phpfreaks.com/topic/210595-simple-affiliate-programs-how-do-they-work/#findComment-1099522 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.