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>