以前我用这个散列我的密码
$password = hash('sha256' , $salt.$password_arr[$i]);
在 config.php 中,我有这段代码来加盐密码
$salt = 'jhfdkjdhfTyhdh3365@jdh69kkshhQAAAiyeg';
因此,当我向其中注册新通行证时,我的 sql 数据库会显示哈希码,对此我很满意,但是当我登录时,它似乎无法识别我的密码,因为身份验证是直接从数据库数据中进行身份验证的。那么我该怎么做才能让它发挥作用
这是我的登录验证代码
<?php
session_start();
include('adminconfig.php');
// username and password sent from form
$username=$_POST['userID'];
$password=$_POST['password'];
// To protect MySQL injection (more detail about MySQL injection)
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM admin WHERE ID='$username' and
password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($result && $count==1){
$_SESSION['userID']= $_POST['userID'];
header('location:adminprofile.php');
}
else {
header('location:adminmessage.php');
die;
}
?>
</body>
</html>