1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Temporary Password Creator

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

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    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,285
    Likes Received:
    364
    Trophy Points:
    83

Share This Page