Generating Random Password using PHP code?

echo password_generate(6,6);

function password_generate($min=6,$max=6){

/*has a default minimum value of 6  and maximum value of 6*/


// this variable is for to save generated password



if(($num >= 97 && $num <= 122)) $pwd.=chr($num);

else if(($num >= 65 && $num <= 90)) $pwd.=chr($num);

else if(($num >=48 && $num <= 57)) $pwd.=chr($num);

else $i–;

return $password;

// returns the generated password


It displays the random password feild with using the php code.

Hope this will be useful.

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *