This is one I like to use jozef.

function generate_password($length = 10) {
  $allowable_characters = "abcdefghjkmnopqrstuvwxyz23456789";
  $ps_len = strlen($allowable_characters);
  $pass = "";
  for($i = 0; $i < $length; $i++) {
   $pass .= $allowable_characters[mt_rand(0,$ps_len-1)];
return $pass;

Its been working well for me for sometime.

-Wendell Frohwein

-----Original Message-----
From: J. Connolly [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 08, 2005 11:41 AM
To: PHP list
Subject: [PHP-DB] Random Password problem

I am using this php in order to create, store and send random passwords 
to people who want to join my mailing list.

function random_password () {
$seed = (integer) md5(microtime());
$password = mt_rand(1,99999999);
$password = substr(md5($password), 3,9);
return $password;

$msg = random_password();
echo $msg;

I seem to be getting the same number very often which makes me fear that

this is not so random. I am a noob so I do not know if this is 
coincidence or a fault in my coding.
Right now, I have been setting up passwords manually, but would like 
users to be as free from me as possible. Any direction would be helpful.

BTW, I keep getting the following number an absurd amount of times. I 
have deleted cookies and even gone to other machines, and yet it still 
generates this number.


Thank you,

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to