View Single Post
  #1  
Old 15th November 2016, 16:24
Chez's Avatar
Chez Chez is offline
Senior Member
 
Join Date: Sep 2011
P2P
Posts: 278
Default [MOD] Random Password Generator
This will generate a random password when you signup.

Click the image to open in full size.

In signup.php after:

PHP Code:
if ($arr[0] >= $maxusers)
        die(
"The current user account limit (" number_format($maxusers) . ") has been reached. Inactive accounts are pruned all the time, please check back again later...");

?> 
ADD

PHP Code:
<script language="JavaScript"> function randomPassword(length) {   chars "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ234567890";   pass "";   for(x=0;x<length;x++)   {     Math.floor(Math.random() * 62);     pass += chars.charAt(i);   }   return pass; } function randomPass() {   pass randomPassword('7');   document.getElementById('p1').value pass;   document.getElementById('p1').type "text";   document.getElementById('p2').value pass; } </script> 
THEN FIND:


PHP Code:
<input type="password" size="40" name="wantpassword"/> 
AND

PHP Code:
<input type="password" size="40" name="passagain"/> 
REPLACE WITH:

PHP Code:
<input type="password" size="40" name="wantpassword" id="p1"/> 
PHP Code:
<input type="password" size="40" name="passagain" id="p2"/> 

AFTER DOING THAT WE NEED TO ADD THE BUTTON:

In my case after:

PHP Code:
<input type="password" size="40" name="wantpassword" id="p1"/> 
ADD THIS:

PHP Code:
<input type="button" value="Generate" onclick="randomPass();" /> 
Thats it!

NOTE: If you want to change the password lenght just edit this line where 7 is the number of letters generated:

PHP Code:
pass randomPassword('7'); 
You can also change the characters too in this line:

PHP Code:
chars "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ234567890"
__________________
http://www.bvlist.com/images/avatars/signaturepics/sigpic16443_2.gif
Reply With Quote
The Following 4 Users Say Thank You to Chez For This Useful Post:
EagleLake (28th May 2018), Fynnon (19th May 2018), iforgot (23rd May 2017), Phogo (15th November 2016)