I have created E-commerce website, In user system, I created referral system works like this -> When a visitor create an account then unique referral code for that customer will be generated. I fear that referral code should not be matched when I'll have a lot of users. So, I wanna create unique referral code.
I am creating like this:
$referral_code = strtolower(substr($first_name,0,3)).$this->refer_code(3);
public function refer_code($limit){
return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
}
Here, I am picking first 3 letters from user name and 3 random letters. It's generating referral code like this:
illqhx
But my boss said that It's very difficult to read and tell to other. So, he wants that referral code should be only numbers or 3 letters from name and 3 numbers should be generated automatically and it should be unique, and limit should be 5 or 6.
Please help me