/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function generatePassword ($length = 8) { $password = ""; $possible = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-$!?]["; $i = 0; // add random characters to $password until $length is reached while ($i < $length) { // pick a random character from the possible ones // we don't want this character if it's already in the password $password .= $char; $i++; } } return $password; }
Comments
