PDA

View Full Version : referral system



assuredlonewolf
26 Oct 2010, 05:46 PM
How is a referral system made with php.

kwikweb
28 Oct 2010, 10:40 PM
Unfortunately that question is fairly vague but I will try and answer it none the less for you.

Generally an HTML form is made where a user fills out his contact details to sign up for a referral program.
The form will post it's results probably to some sort of server-side code for example it could be some PHP code.
The PHP code validated the data and the writes the customer details to a database also generating a unique identifier for that user. This could be numbers or letters or both as long as it is unique and stored somewhere in the database and associated with the member that signed up.
You will then provide to the member a link that they can then share to others. This is their unique referral link. It can be something like "http://www.yoursitehere.com/?ref=uniqueid"
Whats important is that there must be some code running on every page of your site that checks to see if the "ref" query string variable exists and if it does to store a client-side cookie to say that this is a refferal from whoever that unique id belongs to.
When the refferree actually completes and action on your site for example buys something, you then check to see if the client-side cookie exists and if it does, you lookup that unique id and then associate the commission to that user.

I really hope that I have just answered your question.