IF User Forget His Password ? and Activation Email

saqib389saqib389 BeginnerLink Clerk
how can user retreive his password if he forget his password ?
any idea or any code you refer.... or tutorials ?


and next question is......
when user registered then one mail send to his email address which he provide during registration... .
and activation link sent to him and when he click on actigviate link then his registration should activate...

please help me...!

Comments

  • NuvoNuvo Forum Leader VPS - Virtual Prince of the Server
    First question:
    Chances are, you're using MD5 to generate the password in a PHP script.
    The thing is, MD5 isn't strictly encryption, it's a 32bit hashing algorythm, meaning that whatever you use md5() on turns into a unique 32 character alpha numeric string (no two different inputs should generate the same MD5 hash).
    The only way to have account recovery without going to some lengths to crack MD5 (in order to do this, you'd need to have an app which could grab the hashed password from the DB and run it against a dictionary of words, but the chances of this working if the user has a decent password are pretty much nothing).
    Your best bet would be to generate a new password and send the user that before hashing it and inserting it into the database, overwriting the old password.

    Second question:
    I don't know much about using PHP's mail functionality as I haven't done anything much with it, but I'm pretty sure google will have links to tutorials on PHP mail functions as PHP is well documented.
    PHP, CSS, XHTML, Delphi, Ruby on Rails & more.
    Current project: CMS Object.
    Most recent change: Theme support is up and running... So long as I use my theme resource loaders instead of that in the Rails plug-in.
    Release date: NEVER!!!
  • saqib389saqib389 Beginner Link Clerk
    actually i m new in PHP.. so dont know abt too much code
    so it will b easy for me if u ppl refer me any code or tutorials
  • NuvoNuvo Forum Leader VPS - Virtual Prince of the Server
    Basically, to change the password, you'd need to do something like this...
    Assuming your new password will be flower:
    [php]
    $pass = md5("flower");
    $insert = mysql_query("UPDATE yourusertable SET password='".$pass."' WHERE username = 'theaccountyouarechanging'") or die("DIED!!");
    [/php]
    Then you just send the user the password, which is flower :D

    I'm assuming you're already connected to the database... If not, I can help you with that, or you could look through DD's tutorial listing.
    PHP, CSS, XHTML, Delphi, Ruby on Rails & more.
    Current project: CMS Object.
    Most recent change: Theme support is up and running... So long as I use my theme resource loaders instead of that in the Rails plug-in.
    Release date: NEVER!!!
  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    as far as the activation thing is concerned, you need to have a script that creates a random number and then sends it to the user.
    he should click on the like ex. www.ursite.com/activate.php?act=532rwerr55
    and then your activation script will check in the database[PHP]
    mysql_query("SELECT * FROM users WHERE actkey = '$act'[/PHP]

    assuming that you turned the activation key into a variable, [PHP]$act = $_GET;[/PHP]


    PHP Mail Function:


    once the user registers, turn the email value into a variable
    [PHP]$email = $_POST;[/PHP]

    then use phps mail() function as such:
    [PHP]mail(STRING TO, "STRING SUBJECT", "STRING MESSAGE"[/PHP]

    maybe this can do a better job of explaining:
    http://us2.php.net/function.mail

    so...
    [PHP]
    mail($email, $subject, $message[/PHP]

    assuming you put all your information into variables

    and that should work

    maybe someone else can explain better
    ban1.gif
Sign In or Register to comment.