I am presently working on building an user referral tracking script in PHP , MySql . As per the plan , any user who completes the registration will be given a referral link as well as he can share info about my application on Facebook and Twitter .
Now , untill and unless this user brings at least 5 more users to my site , he won;t be allowed to view the home page .
Now , how can I track the number of referred persons that this user brings ?
1.If I use $_HTTP_REFERRER - In this case I can get the link from where the user has landed onto my page . If this is my referral link then I can update the database entry for this user , and the number of referred persons + 1. But , how reliable is $_HTTP_REFERRER ?
2.If I use to track through cookie : Here I am a bit confused as to whether I have to set the cookies for each and every browser or is there any browser independent cookie setting method ? During setting the cookie , how I should save it , I mean should I use only referral id or should I use a combination of referral id and site_id(or any other rcombination).
Also , I should save the referral info in a database . What should be the ideal table schema for this table . I have planned something like : (user_id,user_name,no_of_referrals,referred_by).