1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Rep Power

    How to create a forgot password in login page?


    I want to create a forgot password in my login page.

    This is my codings but i am getting error.
    The erroe is. "no such login in the system. please try again..


    mysql_connect("localhost", "root", "") or die(mysql_error());
    mysql_select_db("recruiter") or die(mysql_error());

    $id = $_POST['id'];
    $sql="SELECT * FROM login WHERE id='.$id.'";
    $r = mysql_query($sql);
    if(!$r) {


    print $err;



    print "no such login in the system. please try again.";

    else {




    $subject="your password";


    $content="your password is ".$password;

    mail($email, $subject, $row, $header);

    print "An email containing the password has been sent to you";



    <form name="forgot" method="post" action="forgot_password.php">
    Enter ur id:
    <input name="id" type="text" value="" />

    <input type="submit" name="submit" value="submit"/>
    <input type="reset" name="reset" value="reset"/>


    Please solve me.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Rep Power
    1) Please enclose your PHP code in [ PHP ] tags. See ManiacDan's New User Guide.
    2) You are using the wrong function for a non-update query. You want 'mysql_num_rows' not 'mysql_affected_rows'. For a SELECT there are no affected rows.
    3) You should should not be using the depreciated mysql extensions. Switch to PDO.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. A Change of Season
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2004
    Next Door
    Rep Power
    This is not secure
    PHP Code:
    mysql_connect("localhost""root""") or die(mysql_error());
    mysql_select_db("recruiter") or die(mysql_error()); 
    You don't need
    SELECT *
    * is not necessary, just get email column and in stead of emailing them the password, you have to send them a link they can follow and choose the new password. When they reset it salt it and do not keep a copy of the none- encrypted password in the database. Place your code between php tags and brush your teeth before you go to bed.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Rep Power
    Here I’m getting to simply offer you the particular code required, if a user forgets their countersign. You in fact got to embrace the code that connects to the info along side all of your hypertext markup language, CSS and JavaScript code. All of this code would reside between the body tags of your hypertext markup language.

    The script asks for associate degree email address. we have a tendency to then make certain the e-mail belongs to a legitimate user. we alter that users countersign and email it back to them.

    if (isset($_POST['submitted'])) the shape.

    if (empty($_POST['email'])) { // Validate the e-mail address.

    $uid = FALSE;

    echo ‘

    You forgot to enter your email address!

    Checks if the shape below has been submitted. Then it checks that associate degree email address has been entered with the empty() operate. If not we have a tendency to warn the traveller.

    } else wherever email=’”. escape_data($_POST['email']) . “‘”;

    $result = mysql_query ($query) or trigger_error(“Query: $query\n
    MySQL Error: ” . mysql_error());

IMN logo majestic logo threadwatch logo seochat tools logo