note 61662 deleted from function.rand by felipe

From: Date: Sun, 30 Dec 2007 18:44:37 +0000
Subject: note 61662 deleted from function.rand by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134438@lists.php.net to get a copy of this message
Note Submitter: jon at zerogen dot co dot uk ---- I know the code is a bit crappy but i use this to generate a random code $acceptedChars = 'azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN0123456789'; $max = strlen($acceptedChars)-1; $code1 = null; for($i=0; $i < 6; $i++) { $code1 .= $acceptedChars{mt_rand(0, $max)}; } $ttcode1 = $code1 . $email . time(); $ttcode2 = md5($ttcode1); $ttcode = substr($ttcode2,0,10); it grabs a random 6 digit code, then adds the email address and the time stamp, md5 all of that then i've got a unique code

« previous php.notes (#134438) next »