note 61662 deleted from function.rand by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.