我如何比较sha1?我认为是正确的是错误的。对此的任何帮助都会很甜蜜,谢谢:)我不明白为什么这不起作用。
<?php
//processlogin.php
session_start();
require('config.php');
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
$hashedpassword = sha1($password);
$sql = "select * from users where username = '$username' and password = '$hashedpassword' ";
$result = mysql_query($sql) or die ( mysql_error() );
$count = mysql_num_rows($result);
$row = mysql_fetch_row($result);
if ($count == 1) {
$_SESSION['loggedIn'] = "true";
$_SESSION['username'] = $row['username'];
$_SESSION['email'] = $row['email'];
header("Location: welcome.php");
} else {
$_SESSION['loggedIn'] = "false";
header("Location: error.php");
}
?>
答案 0 :(得分:0)
您将密码哈希保存在数据库中,然后将其与此进行比较。 或者你加载你拥有的用户名的传递,并将其哈希,然后将其与输入的用户名进行比较!