0

Hello to all,m kawal had rcecntly started my carrier in php so requests to help me in my
projects....
I wana know how to generate a password by the admin panel itself..for ex.If if m running a company and handling admin panel,how can i generate a password to a new user everytime with php and mysql theories...
pls help me at the earliest..

thanks a lot...

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by CobRalf
0

This is the function I use:
(sorry, I do not know from where I got it...it's not mine...)

function generatePassword($length=9, $strength=0) {
	$vowels = 'aeuy';
	$consonants = 'bdghjmnpqrstvz';
	if ($strength & 1) {
		$consonants .= 'BDGHJLMNPQRSTVWXZ';
	}
	if ($strength & 2) {
		$vowels .= "AEUY";
	}
	if ($strength & 4) {
		$consonants .= '23456789';
	}
	if ($strength & 8) {
		$consonants .= '@#$%';
	}
 
	$password = '';
	$alt = time() % 2;
	for ($i = 0; $i < $length; $i++) {
		if ($alt == 1) {
			$password .= $consonants[(rand() % strlen($consonants))];
			$alt = 0;
		} else {
			$password .= $vowels[(rand() % strlen($vowels))];
			$alt = 1;
		}
	}
	return $password;
}

Greetings,
CobRalf

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.