15
Aug
2014

PHP Password Generator

Posted in: PHP, Script 1 Comment

PHP Password Generator
This is a simple PHP password generator script. It will generate 12 characters random password every time you click the generate button. The password will be combination of:

  • 3 lower case letters
  • 3 uppercase letters
  • 3 numeric digits
  • 3 special characters

PHP Password Generator Code

<?php 
	$str1 = "abcdefghijklmnopqrstuvwxyz";
	$str2 = "1234567890";
	$str3 ="`~!@#$%^&*(_-+=)|]}{['';:/?.>,<";
	$str4 ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	$shuffle1 = str_shuffle($str1);
	$shuffle2 = str_shuffle($str2);
	$shuffle3 = str_shuffle($str3);
	$shuffle4 = str_shuffle($str4);
	$pass1 = substr($shuffle1, 0 , 3);
	$pass2 = substr($shuffle2, 0 , 3);
	$pass3 = substr($shuffle3, 0 , 3);
	$pass4 = substr($shuffle4, 0 , 3);
	$password = "$pass1$pass2$pass3$pass4";
	$password2 = str_shuffle($password);
	
?>
<?php
	echo '<div>';
	if (isset($_POST['generator'])) {
		echo $password2;
	} else {
		echo '';
	}
	echo '</div>';
?>

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
	<input type="submit" name="generator" value="Generate Password" />
</form>

Demo

About the Author

Name: Ravi Shekhar
I love learning and sharing web stuffs.

Share this post

Twitter Facebook Google Buzz Digg StumbleUpon Delicious Technorati
You can skip to the end and leave a response. Pinging is currently not allowed.

1 Comment to "PHP Password Generator"

Add Comments (+)
  1. mehedi says:

    it realy helpfull for developer. thanks for share

Leave a Reply