This function I got from an older post at the forum. I get a warning for "Warning: rand(): Invalid range: 65..26 in" and "Warning: rand(): Invalid range: 97..26 in", multiple times since the function is looped. But it does generate a password. The problem is, it's always 89$H-4O. Not very random =).
Regards,
Stig
function MakePassword($length = 7)
{
// purpose: return a random password of length $length
srand( (double) microtime() );
$which = "";
$password = "";
for ($i=0; $i < $length; $i++) {
$which = rand(1, 3);
// character will be a digit 2-9
if ( $which == 1 ) $password .= rand(0,10);
// character will be a lowercase letter
elseif ( $which == 2 ) $password .= chr( rand(65, 26) );
// character will be an uppercase letter
elseif ( $which == 3 ) $password .= chr( rand(97, 26) );
}
return $password;
}