Announcement

Collapse
No announcement yet.

"Forgot password" script.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • "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.

    Thank you.

  • #2
    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!

    Comment


    • #3
      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";
      }
      ?>

      Comment


      • #4
        Re: &quot;Forgot password&quot; 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

        Comment


        • #5
          Re: &quot;Forgot password&quot; script.

          Thanks.So how would you modify that particular script?

          Comment


          • #6
            Re: &quot;Forgot password&quot; 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

            Comment


            • #7
              Re: &quot;Forgot password&quot; 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!

              Comment


              • #8
                Re: &quot;Forgot password&quot; 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!

                Comment


                • #9
                  Re: &quot;Forgot password&quot; 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?

                  Comment


                  • #10
                    Re: &quot;Forgot password&quot; 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

                    Comment


                    • #11
                      Re: &quot;Forgot password&quot; 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 ?!

                      Comment


                      • #12
                        Re: &quot;Forgot password&quot; 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!

                        Comment


                        • #13
                          Re: &quot;Forgot password&quot; script.

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

                          Comment


                          • #14
                            Re: &quot;Forgot password&quot; 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!

                            Comment


                            • #15
                              Re: &quot;Forgot password&quot; 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!

                              Comment

                              Working...
                              X