-1
我在使用PDO登录系统时遇到问题。当你使用正确的密码登录,它只会刷新页面,即使形式被连接到&另一个页面,当你登录你会被重定向到“home.php”不“的index.php”登录系统错误 - PDO
<?php
include('./includes/connect.php');
$submit = $_POST['submit'];
$email = sanitize($_POST['email']);
$password = nCrypt(sanitize($_POST['password']));
if(isset($submit)) {
if(isset($email) && isset($password)) {
$query = $pdo->prepare("SELECT password FROM users WHERE email = ?");
$query->bindValue(1, $email);
$query->execute();
$r = $query->fetch();
$pass2 = $r['password'];
$first = $r['first'];
$last = $r['lastname'];
$username = $r['username'];
if(strcasecmp($password, $pass2) == 0) {
$_SESSION['user'] = $r['user'];
$_SESSION['first'] = $r['first'];
$_SESSION['last'] = $r['last'];
$_SESSION['id'] = $r['id'];
header('Location: home.php');
} else {
header('Location: index.php?e=incorrect');
}
} else {
header('Location: index.php?e=empty');
}
}
?>
基本上,当你输入正确的密码时,什么都不会发生。我的形式是:
<!-- index.php -->
<form action="login.php" method="POST">
<legend>Email Address</legend>
<input type="email" name="email" placeholder="Email Address" required><br>
<legend>Password</legend>
<input type="password" name="password" placeholder="Password" required><br>
<input class="btn btn-info" type="submit" name="submit" value="Login">
</form>
正如你可以看到它链接到另一个页面,然而,当,当你在正确的密码输入,它只会刷新页面的形式是,当它想将您重定向到“home.php”。
我得到它的工作,谢谢。我感到非常愚蠢的lmao。我只是再看看查询。 – user2671870
没有汗水,我们都这样做。接近问题看明显。 – RiggsFolly