unsure how I can do this, i am fairly new at PHP, I am still learning and have self taught myself from reading ALOT.
My question is how can I have my registered users receive a code in their email a three digit code, that is pulled from a data base of 999 codes, that can only be used once? it selects a new code each time.
Also there will be referers so if code 011 refers a friend their friends will say yes 011 referred me and the database will keep track of any linked codes from referrals.
Seems way out of my league if anyone can help please let me know.
I appreciate all the help I can get thank you!
Pretty simple, you have a couple options. One simple solution is to have a table with all the possible codes and a field for the username/id/identifier of the person who consumed the code.
For example, [code_id], [user_id]
As such, you can simply query the table for a row with an empty [user_id] to access a new unused code. Additionally, in the table with users (assuming you have one), keep a [referral_code] column with the code that the person was referred by. Subsequently you can aggregate referrals with simple queries thereafter.