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

时间:2014-12-16 17:10:30

标签: php html

我有一个CMS,我正在创建一个忘记的密码页面,该页面将要求用户输入一个电子邮件地址,代码将在数据库中找到并发送一封电子邮件,在我的数据库中,我有多个用户分配到一个电子邮件地址的帐户 我想要它,以便如果用户输入一个电子邮件地址,并且分配了多个帐户,要发送错误消息说请联系您的管理员,但是atm,它不会这样做。有什么建议吗?

这是我忘记的密码页码:

                    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";
        }
}

我从不同的文件中获取信息,这是我获取数据库的代码的片段:

 $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;
    }

1 个答案:

答案 0 :(得分:0)

更新以下代码:



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; 
}




然后在那里检查$ found变量执行这些更新



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());
}
&#13;
&#13;
&#13;