views:

127

answers:

2

Hi, as title said, how to do or what are the practices to do a system, that if the user refer to a friends (up to 10), he will get rewards per person in php and mysql? Do I need to do in cookies or database? What are the required columns if using database? How to send multiple emails?

+3  A: 

Each registered user gets a unique ID in your system. When they log in, you show them a URL that they are supposed to send to their friends. That URL contains the info on that person - i.e. "register.php?friendThatReferredMe=452".

When the friend completes the registration form, your processing code looks at the URL param of "who referred them", and based on that data, adds rewards to the relevant referrer.

Alex
is it east to hack by just putting the id number? what if I change the number from 452 to 455, it will rewards to others person, isn it?
yes, the rewards will go to another person. That's why it may make sense to do things like "include the ID of that person + salted hash of that id", so that just changing the URL wouldn't do it, and you'd be able to detect fraudulent activity.
Alex
A: 

Alex's solution works fine.

However, if you don't want to have the referrer's ID in your url, you can simply ask the new user to type the username of the referrer in the registration form.

And if you are concerned that people might be dishonest by entering a wrong username, personally i'd be more tempted to enter a random number in the query string !

GuiSim