PHP set Hash 与 Swift 应用程序的 Checked hash 不同

标签 php mysql sql swift hash

我正在尝试使用 PHP 为密码设置哈希,我设置密码的代码是:

$user = $_POST['email'];
$pass = $_POST['password'];
$hashed = hash("md5", $pass);
$sql = "UPDATE Users set password=" . $hashed . " where email=" . email;

这会将密码设置为散列版本,如我所愿。 但是当我尝试检查时,使用:

$user = $_POST['email'];
$pass = $_POST['password'];
$hashed = hash("md5", $pass);
$sql = "SELECT * FROM Users where email=" . $user . " and password=" . $hashed;

使用完全相同的输入,代码不会返回任何内容。有谁知道为什么?我不确定它是否相关,但我正在使用 Swift 应用程序进行发布。

最佳答案

$user = $_POST['email'];
$pass = $_POST['password'];
$hashed = hash("md5", $pass);
$sql = "UPDATE Users set password='" . $hashed . "' where email='" . email . "'";


$user = $_POST['email'];
$pass = $_POST['password'];
$hashed = hash("md5", $pass);
$sql = "SELECT * FROM Users where email='" . $user . "' and password='" . $hashed . ''';

关于PHP set Hash 与 Swift 应用程序的 Checked hash 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28666938/

相关文章:

php - 更改表保存问题中的值

php - 警告 : mysql_query(): 25 is not a valid MySQL-Link resource in/home/. .../classes/class_core.php 第 60 行

php - 使用 PHP 在 MySQL 中搜索完全匹配的单词

php - 如何根据类别获取产品

mysql - 仅当超过 n 行时才删除值较低的行

php - Metabox 选择数组在自定义列中显示帖子 ID 而不是帖子名称

php - 使用swift2插入数据库

mysql - 如何从 hibernate 表中选择多条记录

php - 数据库设计: How to record bundle product deliveries

Java Setters 和 Getters 将数据存入 Java 数据库