This tutorial is going to show you how to make a password generator.
You might have a website where your users security is very important and you would prefer to set a password for them rather than them set their own. Well here is a very simple yet flexible method in which you can create completly random passwords.
The first thing we need to do is define all of our functions. In this script there are 3. $minimum for the minimum ammount of characters to be in the password. $maximum for the maximum ammount of characters. And $password for the password which has been created.
So we define these using this code:
$minimum=7;
$maximum=15;
$password="";
Next we have to select random characters which is done by the following bit of code…
for($i=0;$i
{
$number=rand(48,122);
if(($number > 97 && $number < 122))
{
$password.=chr($number);
}
else if(($number > 65 && $number < 90))
{
$password.=chr($number);
}
else if(($number >48 && $number < 57))
{
$password.=chr($number);
}
else if($number==95)
{
$password.=chr($number);
}
else
{
$i–;
}
}
Now that is the password created. Now we just have to show it. You do this using this code:
echo $password;
Fairly simple, just the randomising bit which can get complicated.






































October 15th, 2008 at 5:46 pm
Cool. Im going to use this on my site :)
November 23rd, 2008 at 7:27 pm
Hi! Your Post “” is very interesting for me. Unfortunately my written English is not so good so I write in German: Dir, meinem liebsten, geh