Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

password field

Status
Not open for further replies.

scudwork

Programmer
Jan 28, 2002
1
US
I'm newbie to PHP so bare with me.

On our intranet we maintain a web site that allows our business partners some administration tasks. The cgi is in Perl and the form is HTML/Javascript on UNIX OS running Apache. One particular page allows the business group to set up access accounts for users. It works well. The problem is this group wants a pre-populated password field. I found a Perl module that Generates Passwords. I'd need to embed the Javascript and HTML within the Perl cgi to get the page loaded with the password in the form.

If I'm heading towards more dynamic pages then well...maybe rewrite the page in PHP or even the whole app(once I figure out how). Can I install PHP and deal just with the password field population without a complete rewrite in PHP? My brand new OReilly book Programming PHP has a "system" function that hopefully will execute my Perl password generator, any helpful advise here would be much appreciated.
Thanks in advance! Eric

 
If i understand you correctly, you're just trying to generate a password for new users, so they don't have create one. You can use a random string generator to do this.
Code:
$charlist = "ABCDEFGHJKMNPQRSTUVWXYZbcdefghjkmnpqrstuvwxyz23456789!@#$%^&*";
	$password = "";
	$max = strlen($charlist)-1;
	for($i=0; $i < 8; $i++) {
		$password .= $charlist{mt_rand(0, $max)};
	}

Just substitute the 12 for how long you want the password.
 
you could also look at uniqid() as a function.

there is also a pear class that will generate human readable password string for you. Text_Password.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top