-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