忘记密码页帮助[PHP / HTML]

问题描述:

I have a CMS, I am creating a forgotten password page, the page will require a user to enter an email address and the code will find it in the database and send them an email, in my database, i have multiple users accounts assigned to one email address. I want it so that if the user enters an email address and it was more than one account assigned to it, to error a message saying please contact your admin, but atm, it is not doing this. Any suggestions?

Here is my forgotten password page code:

                    if ($lookup) {
                        $user->sendPasswordResetEmail();
                        echo"sent email";
                        } elseif ($lookup) {
                            echo "please contact your admin";
                                }else{ 
                                $echo"Can't find user";
                                }
            }
    }else{
        echo "please enter an email address";
        }
}

I take the information from a different file, here is the snippet for the code where I take the database:

 $resetsystem = $db->query($qry);
 if ($resetsystem && $resetsystem->num_rows == 1) {
 $that->setUserData($rs->fetch_assoc());
 return true;
        }
            if ($resetsystem && $resetsystem->num_rows > 1) {
                return;
            }
        return false;
    }

update following code:

function lookupByEmail($userID) { 
  global $db; 
  $this->id = $userID; $qry = " SELECT user_id, user_first_name, user_last_name, user_username, user_email, user_suspended FROM cms_users WHERE user_email = " . $db->SQLString($this->id) . " AND user_deleted
= 0;"; 
$rs = $db->query($qry); 
if ($rs && $rs->num_rows == 1) { 
  $this->setUserData($rs->fetch_assoc()); 
  return 1; 
} 
if ($rs && $rs->num_rows > 1) { 
  return 2; 
} 
return 0; 
}

and then where you are checking the $found variable do these updates

if ((int)$found == 1) {
  $user->sendPasswordResetEmail();
  $str_Message = '<div class="success_message">User found, an email has been dispatched to you.</div>';
} elseif ((int)$found > 1) {
  $errors->defineError("too_many_users", "please contact your admin", array());
}else{ 
  $errors->defineError("user_not_found", "The specified user could not be found.  Please try again.", array());
}

</div>