I have a mysql table which will store users email addresses once submitted (each is unique and is the primary field) and a timestamp.
I have added another column called 'unique_code' (varchar(64), utf8_unicode_ci).
What I would very much appreciate assistance with is;
a) Generating a 5 digit alphanumeric code, ie: 5ABH6
b) Check all rows in the ‘unique_code’ column to ensure it is unique, otherwise re-generate and check again
c) Insert the uniquely generated 5 digit alphanumeric code into 'unique_code' column, corresponding to the email address just entered.
d) display the code on screen.
What is the best way to create this with my above code? And how can I then do a check of the unique code column (to avoid multiple users having the same referral code) and insert it there, in the same row as the user?
But with that $referral, it must go through a check of the unique_code column in the db, row by row, if unique, assign that users row with the code, otherwise regenerate, check and then assign.
Any chance you could help update my code in my original post?