比较用户密码时出错

时间:2016-02-02 14:29:41

标签: php mysql

我已经散列了密码并在数据库中存储了密码,如TEXT,密码不匹配。我在数据库的密码字段中使用了 <?php $submit=isset($_POST['submit']); if($submit) { $first=$_POST['first']; $password=$_POST['password']; $hash='$2y$10$KWTn41ESI0AOW1io5efht..x4KWfcpbb9ztotxUGrrM...'; $password=password_verify($password,$hash); $db = new mysqli("localhost", "root","","learndb"); $sql = "select * from admin where username = '" . $first . "' and password = '". $password . "'"; $result = $db->query($sql); $result=mysqli_num_rows($result); if($result>0) { session_start(); $_SESSION['logged_in'] = true; session_regenerate_id(true); header("Location:loginhome.php"); } }

VCS trigger

0 个答案:

没有答案