首页 > 解决方案 > 我的查询仅针对一个帐户执行

问题描述

所以我有一个数据库,我在其中存储用户信息以供他们登录或重置密码。问题是重置密码只对一个用户有效,对任何其他用户都无效。

我已经尝试比较这两个用户,以找出它不工作的用户有或没有工作的用户有什么,尽管我没有看到任何区别,这是我的数据库的图片来可视化它:https://gyazo.com/f231937058bc4c99ffa6bf1f9a5f7631

重置密码代码:

$email = $_GET['email'];
$token = $_GET['token'];

$stmt = $connection->prepare("SELECT email FROM users WHERE token = ? AND tokenexpire > NOW()");
$stmt->bind_param('s', $token);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_array(MYSQLI_ASSOC);

if ($result->num_rows > 0 && md5($row['email']) == $email) {
    $hash = $algorithm->create_hash($_POST['password']) // the create hash function comes from a PBKDF2 class from github

    $token = ''; 
    $normal_email = $row['email']; // the email on the top is a hashed email with md5

    $query = $connection->prepare("UPDATE users SET hash = ?, token = ? WHERE email = ?");
    $query->bind_param('sss', $hash, $token, $normal_email);
    $query->execute(); // thats the line that does get executed on the 'nex' account but it doesn't on the 'veruz' account

没有错误信息

标签: phpmysql

解决方案


推荐阅读