FREE tutorial,solution,RSS Feeds on Operating Systems, Programming, Web Development, Applications, Databases, Networking, Hardware, Security, SEO Free Expertsforge Membership
Join us as Moderator
Submit Article to Expertsforge.com Submit Article My Expertsforge
 
RSS Feeds, Help Help RSS Feeds
bannertop
 

PHP Tutorial: Generate random password that includes numbers and letters

jawahar
5/2/2005 1:19:01 AM, Views: 4270
The following code illustrates an excellent password generator.

<?php
echo password_gen(6,6);
function password_gen($min=6,$max=6){ /*has a default min value of 6
and maximum value of 6*/
$pwd=""; // to store generated password
for($i=0;$i<rand($min,$max);$i++){
  $num=rand(48,122);
  if(($num >= 97 && $num <= 122))     $pwd.=chr($num);
  else if(($num >= 65 && $num <= 90))  $pwd.=chr($num);
  else if(($num >=48 && $num <= 57))    $pwd.=chr($num);
  else    $i--;
}
return $pwd;
}
?>
Next Steps:
Add this Tutorial to:
Blink Blink del.icio.ous Del.icio.us Digg Digg
Fark Fark Furl Furl Google Google
Reddit Reddit Simpy Simpy Spurl Spurl
Technorati Technorati Windows Live Win Live Yahoo Yahoo
Rate Me!
Avg Visitor Rating: Average Visitor Rating is 3.5 out of 5
Number of Ratings : 3 Votes
Rate:
Send Private MessageSend Message
Signup / Login To View the Solution or Provide Comments
Post Comment/Solution
Comment:*
        (Link Rules) 
  Use : [bold] for <b>; [/bold] for </b>; [italic] for <i>; [/italic] for </i>; [code] & [/code] for code
 
Categories
Options
PHP RSS Feed
Most Popular Tutorial
Most Popular Solution
No Records!
Top Rated
Top Rankers
Overall
1. jawahar (500)
Yearly -2008
No Rankings!
Expertsforge Sponsors
bnrtop