嗨创建一个登录屏幕,当表单提交时,它会转到另一个script.php。 当密码错误时,我想回到我的登录屏幕(index.php),并在浏览器中显示错误消息。我该怎么做 ?如何前往页面php
我想这样,但我不工作
$sql = "SELECT * FROM studentlogin WHERE studentid = '$lecturerid' AND password = '$password'";
$result = $conn->query($sql);
if(!$row = $result->fetch_assoc()){
header("Location: index.php")
}else {
echo "Login successful";
}
?>
'Location:index.php?error = login + failed' then on index.php check for'$ _GET ['error']'。 – chris85
您的SQL对SQL注入开放。你应该参数化你的查询。也希望密码被散列。 – chris85
提示:将错误消息存储在会话变量中。帮助防止URL操作 – Akintunde007