Generating Random Password in PHP :

Generating Random Password in PHP :

Here is an example to create a function that generates a random password.

We will call the function randomgeneratepass():

<?

function randomgeneratepass()

$charslist = “1234567890abcdefGHIJKLMNOPQRSTUVWxyzABCDEF
ghijklmnopqrstuvwXYZ1234567890″;

$thepass = ‘’;

for($i=0;$i<7;$i++)

{

$pass .= $charslist{rand() % 39};

}

return $pass;

}

//we can use the function as follows

$password=randomgeneratepass();

?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.