Generating unique strings for email activation links PHP -


my question bit tricky , couldn’t find right manner in efficiently articulate it. i’m creating unique activation string/link combines hashed username , time in php. exact time gets data sent database , actual time takes send email activation link user’s email account different (maybe in milliseconds , seconds)-and means have different email activation links database , email account. let me show code snippet:

$username = $_post[‘username’]; $table = ‘users’; $activate_field = ‘activate’; $activate_code = md5($_post[‘username’]) +  time(); //provides unique code activating //few more lines of code then… $query = $connect-> prepare(“insert $table $acivate_field values $activate_code”); $query->execute();  //then long code sending email activation code appended user’s email account 

is there better way of generating unique strings every second maybe? time , appreciate and/or suggestions.p.s i'm using phpmailer sending emails.

uuid() in mysql better uniqid() in php prefix of microtime can shot.


Comments