Generating Random Password using PHP code?

in PHP Code / No Comments

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.

With more than 8 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]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>