This function GenRandomPassword() generates a random password of x characters long. This function is very useful to generate a password for your new registered customers.
<?php
#This function generates a random password of x characters long. function GenRandomPassword($lenght) { $str = "abcdefghijkmnopqrstuvwxyz0123456789";
srand((double)microtime()*1000000); for ($i=0; $i<$lenght; $i++) { $num = rand() % strlen($str); $tmp = substr($str, $num, 1); $pass = $pass . $tmp; } return $pass; }
#Generate a random password of 8 characters long. $password = GenRandomPassword("8"); echo "You Password: ".$password;
?>
Download Script |