Hi,
I'm creating a user database and at the site launch I intend to generate passwords for each member and then mail them out. I do this by looping around the member table and for each member I call run the function. The problem I am having is that each script I use (taken from free sites), generates the same password for every member. The latest script looks like this :
function genpassword($length){
srand((double)microtime()*100000);
$vowels = array("a", "e", "i", "o", "u");
$cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr",
"cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl");
$num_vowels = count($vowels);
$num_cons = count($cons);
for($i = 0; $i < $length; $i++){
$password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)];
}
return substr($password, 0, $length);
}
I'm fairly sure it's because the script is using the same time once it starts so therefore I'm getting the same result. How can I adjust this so that it will generate different values whilst the time doesn't change.
Thanks