php - 我的查询仅针对一个帐户执行
问题描述
所以我有一个数据库,我在其中存储用户信息以供他们登录或重置密码。问题是重置密码只对一个用户有效,对任何其他用户都无效。
我已经尝试比较这两个用户,以找出它不工作的用户有或没有工作的用户有什么,尽管我没有看到任何区别,这是我的数据库的图片来可视化它: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
没有错误信息
解决方案
推荐阅读
- javascript - 我怎样才能拥有多个元素的可观察和订阅者?
- sqlite - SQLite 按最小差异排序结果
- java - Android Studio 项目在 java 或 xml 中都不能正常工作
- pandas - 在 datetimeindex 末尾添加 10 步
- c - 当尝试在 RayLib 2.6 中绘制矩形时,我发现了这种“流血”效果
- c - CS50 2019 Vigenere - 第二个循环
- powershell - Powershell hashtable.containskey 总是返回 true
- visual-studio-2019 - 从 Visual Studio 2019 将 Hololens 应用程序部署到模拟器时出现问题
- android - Flutter + android在Android中的Firebase Cloud Messaging上接收数据消息
- excel - 在一行的单元格范围内设置背景颜色(不使用条件格式)