• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP, MySQL -- need to generate a 'random id' for verification

Al Neri

Diamond Member
Putting together a site - a user can input information, but I want to require the user to verify it via email -- my idea was to --

Submit it into a table as such

ID----Input----UniqueID----verified
1-----ABC------38fdjf93----0
2-----DFR------f30fkfa----0
3-----RRF------ef9afaef----1

when entered into the webiste email a link to the user with a hotlink to www.mysite.com/verify.php?uid=38fdjf93 , which if the user clicks on the link makes verified=1 which would mean to display it on the display.php page.

What I need is a way to generate a sensibly legnth (not too long) UniqueID. I was thinking base it on the current time and date... is there an easy way to do this?


hope that was english
 
Why not use the users e-mail address combined with the unix timestamp and then md5 it? The unique ID will be 32 chars long but that shouldn't be any problem.
 
I got this function from the PHP site under rand, I did not write it (why reinvent the wheel? The comments section of PHP's site can be quite useful):

function randomkeys($length)
{
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
$key = $pattern{rand(0,35)};
for($i=1;$i<$length;$i++)
{
$key .= $pattern{rand(0,35)};
}
return $key;
}

or MD5/SHA1 involving the time would be fine, just take some substring of that if you want it shorter
 
Back
Top