出于某种原因,我一直尝试登录并不断收到错误消息,即用户名和密码无效。我已经尝试在编码中设置密码而不是使用 post 方法。有人有什么想法吗?
另外,我知道 md5 已经不行了,但是现在 idc 关于这一点,一旦我的所有功能完成,我将切换到 SHA-2,稍后我会对其进行加盐和哈希处理。
<?php
include_once"dbconnection.php";
session_start();
$mysqli = new mysqli($host, $username, $password, $database);
if(isset($_POST['login'])){
if ($stmt = $mysqli->prepare("SELECT email, password FROM users WHERE email=? AND password=? LIMIT 1"))
{
$email = $_POST['email'];
$password = md5($_POST['password']);
$stmt->bind_param('ss', $email, $password);
$stmt->execute();
$stmt->bind_result($email, $password);
$stmt->fetch();
if($stmt->fetch() == true)
{
$_SESSION['Logged'] = 1;
$_SESSION['Email'] = $email;
header('Location: blogzone.php');
exit();
} else {
echo "Wrong Username or Password!";
}
$stmt->close();
}
else
{
}
}
$mysqli->close();
?>
我的 HTML
<form action="login.php" method="post" name="login">
<input type="text" name="email" /><br />
<input type="password" name="password" id="password"/><br />
<input type="submit" value="Login" name="login" />
</form>