php - 登录后如何将用户引导到另一个站点?
问题描述
我知道有很多关于制作登录系统的教程。但奇怪的是我的代码不起作用。
它在 password_verify 之前一直有效。
这是我的 index.php(用于登录)
<form id="sign-in" method="post">
<input id="input" type="text" name="name" tabindex="1" placeholder="Benutzername" required><br>
<input id="input" type="password" name="password" tabindex="2" placeholder="Passwort" required><br>
<input id="input" class="button" type="submit" name="submit" value="Einloggen"><br>
<a href="accounts/account-not-found" id="account-not-found">Account wurde nicht gefunden?</a>
</form>
<?php
if(isset($_POST["submit"])){
require("mysql.php");
$stmt = $mysql->prepare("SELECT * FROM accounts WHERE USERNAME = :user"); //USERNAME CHECK
$stmt->bindParam(":user", $_POST["name"]);
$stmt->execute();
$count = $stmt->rowCount();
if($count == 1){
// USERNAME IST Frei
$row = $stmt->fetch();
if(password_verify($_POST["password"], $row["PASSWORD"])){
session_start();
$_SESSION["name"] = $row["USERNAME"];
header("Location: internal-area/home/");
}
else{
echo "Das Passwort ist falsch"; //GERMAN for Password is wrong
}
}
else{
echo "Der Login ist fehlgeschlagen"; //GERMAN for Login has failed
}
}
?>
我的“内部区域/home/index.php”:
<?php
session_start();
if(!isset($_SESSON["name"])){
header("Location: ../../"); // ../../ leads to my index.php for login (see above)
exit;
}
?>
我希望你能帮助我。如果缺少任何信息,请告诉我:)
丹尼尔。
解决方案
我拼错了
if(!isset($_SESSON["name"])){
header("Location: ../../"); // ../../ leads to my index.php for login (see above)
exit;
}
它必须是 $_SESS I ON["name"]
推荐阅读
- java - 如何创建具有两个 Java 应用程序和 Mysql 服务器的 docker 容器?
- html - 如何在 html 标签中显示从数据库中提取的数据?
- sorting - Delphi Radix Sort 支持负整数
- c++ - 嵌套类的访问说明符有什么用途?
- flutter - 是否可以更改默认的 Flutter 闪屏过渡?
- sql - 比较查找长途航班的日期和时间
- typescript - 汇总构建打字稿错误“意外令牌”
- python - 如何使用 Django 将 CSRF 令牌发送到 ajax 请求?
- c++ - 如何在给定此类信息的情况下打印 c++ 函数参数的内容
- c++ - 使用 Clion IDE 编译 OpenCV 项目失败