ahvceo Posted May 18, 2009 Share Posted May 18, 2009 Hi All, I am 72 and I am just learning php. I have a general question about referals. If I refer some one to a site using my affiliate link how do they know it was me that refered the person to that site? I know my link is coded with a code identifing me but how do they get that code? I would really appreaciate some help with this as it bothers that I might not get paid for refering someone. I might also want to have someone refer people to my site and I would like to pay them for it. Can anyone explain to me how this all works? Thanks ahvceo Link to comment https://forums.phpfreaks.com/topic/158548-solved-how-do-i-find-out-who-refered-a-visitor-to-my-site/ Share on other sites More sharing options...
Masna Posted May 18, 2009 Share Posted May 18, 2009 Variables like a referrer are always stored in URI variables (information included in the URL that brings you to a specific site/page). For example, you might see a link like... http://site.com/signup.php?referrer=ahvceo You can access this referrer variable using the predefined $_GET array: $referrer = $_GET['referrer']; //$referrer now stores your name! Hope this helps! Link to comment https://forums.phpfreaks.com/topic/158548-solved-how-do-i-find-out-who-refered-a-visitor-to-my-site/#findComment-836211 Share on other sites More sharing options...
phpSensei Posted May 18, 2009 Share Posted May 18, 2009 You must generate a UNIQUE code for each user, and use this code to identifiy which user the code belongs to in the data base. There are plenty of ways of doing this, for ex. you can use user's ID in the database, encrypt the id if you like for security reasons. using URI, like the above user said, use the $_GET to retreive the HTTP VAR called "ref" or w.e you like. ref can be "index.php?ref=230983324" so the ref is the USER's ID Link to comment https://forums.phpfreaks.com/topic/158548-solved-how-do-i-find-out-who-refered-a-visitor-to-my-site/#findComment-836213 Share on other sites More sharing options...
ahvceo Posted May 18, 2009 Author Share Posted May 18, 2009 Hi All, Thank much for the quick replies, I really appreciate it. Does the "$referrer = $_GET['referrer'];" statement get any referral id or does it just get the ones that are identified by a particular code. For instance if my referral code is "http://amazinghomeventures.com?ref=ahvceo", would the above statement work or would I use "$referrer = $_GET['ref'];"? Does the statement return "referrer=username or just the username? Does it work if there is an interveining URL? For instance if someone is referred to my site and I send them to PayPal before I try to get the referrers name, can I still get it this way? Thanks again, looking forward to your next reply! ahvceo Link to comment https://forums.phpfreaks.com/topic/158548-solved-how-do-i-find-out-who-refered-a-visitor-to-my-site/#findComment-836234 Share on other sites More sharing options...
Masna Posted May 18, 2009 Share Posted May 18, 2009 Hi All, Thank much for the quick replies, I really appreciate it. Does the "$referrer = $_GET['referrer'];" statement get any referral id or does it just get the ones that are identified by a particular code. For instance if my referral code is "http://amazinghomeventures.com?ref=ahvceo", would the above statement work or would I use "$referrer = $_GET['ref'];"? You would use $referrer = $_GET['ref']; What lies in the $_GET quotes is the name of the variable in the URL. Does the statement return "referrer=username or just the username? Does it work if there is an interveining URL? For instance if someone is referred to my site and I send them to PayPal before I try to get the referrers name, can I still get it this way? Thanks again, looking forward to your next reply! ahvceo Yes, you can still get it. Link to comment https://forums.phpfreaks.com/topic/158548-solved-how-do-i-find-out-who-refered-a-visitor-to-my-site/#findComment-836241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.