Results 1 to 22 of 22

Thread: "Forgot password" script.
      
   

  1. #1
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default "Forgot password" script.

    Hi everybody,
    I am looking for a simple "Forgot password" script for my website.
    By the way you are more than welcome to check out my site that I built with BlueVoda.
    http://www.iqtest4fun.com
    Thank you.

  2. #2
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: "Forgot password" script.

    A forgot password script needs to

    1. Have a user input (usually the username, or user email address)
    2. Verify that this username or email address is registered in the databse
    3. Email, to the registered email address, the login details.

    So the actual coding of this script depends on the structure of your databse table.
    As you understand, there is no way that there can be a script that will suit all cases. It has to be made case by case.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  3. #3
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default Re: "Forgot password" script.

    I found a script but it isn't working.
    Could you please take a look at it and tell me why it keeps giving me
    "no such login in the system. please try again."
    even when I use a loginid that is in my database.

    <?php
    @mysql_pconnect("localhost", "", "") or die("Cannot connect to DB!");
    @mysql_select_db("") or die("Cannot select DB!");
    $sql="SELECT password,email FROM forms WHERE loginid='$loginid'";
    $r = mysql_query($sql);
    if(!$r) {
    $err=mysql_error();
    print $err;
    exit();
    }
    if(mysql_affected_rows()==0){
    print "no such login in the system. please try again.";
    exit();
    }
    else {
    $row=mysql_fetch_array($r);
    $password=$row["password"];
    $email=$row["email"];
    $subject="your password";
    $header="from:ydmmtbz@iqtest4fun.com";
    $content="your password is .$password.";
    mail($email, $subject, $row, $header);
    print "An email containing the password has been sent to you";
    }
    ?>

  4. #4
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: "Forgot password" script.

    That specific script checks for a column called "loginid" from the table "forms" for a value. The script does not collect any data to be checked against the database. (Usually posted data from a form).

    The script has 2 check

    The first checks if the query is successful
    The second checks if a row in the table was found
    If it passes both then it will display the information from the row in the table.

    Yours is failing in the second check

    You need to post the data to the script for it to check the database with

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

  5. #5
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default Re: "Forgot password" script.

    Thanks.So how would you modify that particular script?

  6. #6
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: "Forgot password" script.

    It would depend on the form that the user enters their login id in to have their information emailed.

    Basically, assuming that the "name" attribute of the text field they enter their login id is "loginid", then just add:

    $loginid = $_POST['loginid'];

    Andwhere before this line:

    $sql="SELECT password,email FROM forms WHERE loginid='$loginid'";

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

  7. #7
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: "Forgot password" script.

    1. Create a login form. There the user should type his "loginid" in a fie ld named "loginid". (though usually this is more known as "username rather than "loginid"). Set the form action to be this very script.
    Then, add the lines in red in your script:


    <?php

    $loginid = trim($_POST['loginid']);
    @mysql_pconnect("localhost", "user", "password") or die("Cannot connect to DB!");
    @mysql_select_db("dbname") or die("Cannot select DB!");
    $sql="SELECT password,email FROM forms WHERE loginid='$loginid'";
    $r = mysql_query($sql);
    if(!$r) {
    $err=mysql_error();
    print $err;
    exit();
    }
    if(mysql_affected_rows()==0){
    print "no such login in the system. please try again.";
    exit();
    }
    else {
    $row=mysql_fetch_array($r);
    $password=$row["password"];
    $email=$row["email"];
    $subject="your password";
    $header="from:ydmmtbz@iqtest4fun.com";
    $content="Your password is $password.";
    mail($email, $subject, $content, $header);
    print "An email containing the password has been sent to you";
    }
    ?>
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  8. #8
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: "Forgot password" script.

    Ooops! Sorry Watdaflip. Just had the browser open and didn't see that you had already posted.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  9. #9
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default Re: "Forgot password" script.

    Hi guys,
    I can't figure out why I keep getting the following error:

    Parse error: syntax error, unexpected '=' in /home/.../public_html/forgot.php on line 28

    Any ideas?

  10. #10
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: "Forgot password" script.

    what is line 28 of your script?

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

  11. #11
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default Re: "Forgot password" script.

    This is the entire script:

    <?php
    loginid = trim($_POST['loginid']);
    @mysql_pconnect("localhost", "", "") or die("Cannot connect to DB!");
    @mysql_select_db("") or die("Cannot select DB!");
    $sql="SELECT password,email FROM forms WHERE loginid='$loginid'";
    $r = mysql_query($sql);
    if(!$r) {
    $err=mysql_error();
    print $err;
    exit();
    }
    if(mysql_affected_rows()==0){
    print "no such login in the system. please try again.";
    exit();
    }
    else {
    $row =mysql_fetch_array($r);
    $password=$row["password"];
    $email=$row["email"];
    $subject="your password";
    $header="from:ydmmtbz@iqtest4fun.com";
    $content="your password is .$password.";
    mail($email, $subject, $content, $header);
    print "An email containing the password has been sent to you";
    }
    ?>

    Funny thing is there isn't a line 28 ?!

  12. #12
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: "Forgot password" script.

    Did you by any chance paste the the script in a html page ?
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  13. #13
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default Re: "Forgot password" script.

    No,it is php I just double-checked again.

  14. #14
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: "Forgot password" script.

    It makes no sence. I suggest that you connect with FTP, double click on the "forgot.php" file. Notepad should open with the file content in it. Copy and post here the actual code if it is different from the one you posted.

    Or, if you wish, send me your login details, and i will have an inside look.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  15. #15
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: "Forgot password" script.

    Hi,
    as i thought, you have pasted the script in an empty BV page, which has added some lines of code, that's why the script was givin error in line 28. In fact, there was a $ missing:

    $loginid = trim($_POST['loginid']);

    Fixed and uploaded on the server.

    I also sent you an email but got a message about your mailbox being full.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  16. #16
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default Re: "Forgot password" script.

    Thank you for fixing that.
    Now the problem is that I keep getting "no such login in the system. please try again.".I use a loginid that is in my database and still get that.Can you go back inside and see why?
    Also you mentioned my mailbox being full.When I go to webmail in my control panel it says it is empty!?What is going on?I might be missing important mail from my members and I don't even know it!

  17. #17
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: "Forgot password" script.

    What's the link to the form that sends to the forgot.php ?
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  18. #18
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default Re: "Forgot password" script.

    login.php

  19. #19
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: "Forgot password" script.

    Change the Enctype of your login.php form in "multipart / form data", save and republish
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  20. #20
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default Re: "Forgot password" script.

    GREAT.It is working now.
    By the way what do you say about my mailbox being full when it is in fact empty?

  21. #21
    csabi_fl is offline Sergeant
    Join Date
    Jul 2006
    Posts
    21

    Default Re: "Forgot password" script.

    I think I got it.
    The neomail trash folder filled up my quota.I didn't bother to check the trash folder only the new mail that's why I missed it the first time.
    For everybody out there if this ever happens to you then just raise the quota and your mailbox will never get full even if you forget to check it for a while.
    Navaldesign,thanks for all your help .

  22. #22
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: "Forgot password" script.

    Glad you sorted it. By the way, i did raise your webmail quota to 100 MB
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49