Hi all. I need to write a sort of multi-level referral script
in a membership site,where if a member refers a certain
number of members he goes up one level,and if those
invited members invite the same number of members each, the original
members goes up another level and so on. How do I approach this kind of
situation with PHP...Thanks
Multi Level Referral Script
Moderator: General Moderators
Re: Multi Level Referral Script
You must start with a solid database design.
users:
id
username
level
etc
referredby:
id
referer
referee
timestamp
levels
id
description
In php, you have to generate some unique url for the user so that whoever they refer gets credit for it. There's stuff out there to generate those if you look for it. phpList will have some code for that if you tear it apart.
So when someone clicks the URL (or rather completes the registration process I assume) a query is executed which finds the level of the referer and adds one to it. Presumably this script will do other things like complete the registration too.
Now, go forth and code! If you have specific problems, let us know!
users:
id
username
level
etc
referredby:
id
referer
referee
timestamp
levels
id
description
In php, you have to generate some unique url for the user so that whoever they refer gets credit for it. There's stuff out there to generate those if you look for it. phpList will have some code for that if you tear it apart.
So when someone clicks the URL (or rather completes the registration process I assume) a query is executed which finds the level of the referer and adds one to it. Presumably this script will do other things like complete the registration too.
Now, go forth and code! If you have specific problems, let us know!
Re: Multi Level Referral Script
Thanks.
Yes, the real issue is with the database logic,
can you elaborate more on how those tables are
related...
Yes, the real issue is with the database logic,
can you elaborate more on how those tables are
related...
Re: Multi Level Referral Script
users:bsam wrote:Thanks.
Yes, the real issue is with the database logic,
can you elaborate more on how those tables are
related...
id
username
level (levels.id)
etc
referredby:
id
referer (users.id for the referrer)
referee (users.id for the referrer)
timestamp
levels:
id
description
I'm not sure I can be any more elaborate than that. I'm sure your actual table structure is going to be far more involved than what I've presented, that is just a basic structure. I suggest you go do some reading on database design or you're going to get hopelessly lost trying to do this project because you won't have a meaningful data set.