I have the following pw generation code:
//set the random id length
$random_id_length = 10;
//generate a random id encrypt it and store it in $rnd_id
$rnd_id = crypt(uniqid(rand(),1));
//to remove any slashes that might have come
$rnd_id = strip_tags(stripslashes($rnd_id));
//Removing any . or / and reversing the string
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));
//finally I take the first 10 characters from the $rnd_id
$rnd_id = substr($rnd_id,0,$random_id_length);
echo "Random Id: $rnd_id";
Now I have two problems:
When generating a new pw I need to check first with my database if the pw wasnÃƒÂ¢Ã‚Â€Ã‚Â™t already generated.
I query against the database with this statement:
Select count (*) from pw where uid = $aaa and genpw= $rnd_id
Here if the result is 0 then the generated pw is ok but if the result is not 0 i must generate another.
Now if the pw was already generated I need another pw to be generated and check it again against the database. I need to do this until the pw isnÃƒÂ¢Ã‚Â€Ã‚Â™t already generated.
My second problem is:
When resetting pw I must have the option to select multiple users via check boxes and reset them. What I donÃƒÂ¢Ã‚Â€Ã‚Â™t know is how to generate different pw for all the selected users at the same time and update them with their new pw into the database.
Is what I want to do possible? If yes how can I do it?