Temporary Password Creator

Discussion in 'PHP' started by pradeep, Apr 12, 2005.

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    Many sites send you a temporary password after u sign up with them. Here is is how you too can do that

    PHP:
    function TempPassword($tp_len)
    {
       
    $pstring "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWXxYyZz0123456789";
       
    $plen strlen($pstring);
          for (
    $i 1$i <= $tp_len$i++)
          {
              
    $start rand(0,$plen);
              
    $temp_password.= substr($pstring$start1);
          }

        return 
    $temp_password;
    }

    Example:
    PHP:
    $tp=TempPassword("9");
    Result:
    Code:
    $tp= Ab72Pz3Rs
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice