我尝试在登录后重定向用户,但它无法正常工作。
这是我的代码:
session_start();
include_once 'config.php';
if (isset($_SESSION['username']) != "") {
header("Location: Home.php");
}
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$res = mysql_query("SELECT * FROM employee_login WHERE email = '$username'");
$pass = $_POST['pass'];
$row = mysql_fetch_array($res);
$newpass = $row['pass'];
if ($newpass == $pass && !empty($row)) {
$user_email = $row['email'];
$_SESSION['username'] = $user_email;
$username = $_SESSION['username'];
if ($_SESSION['username'] == "abc@gmail.con") {
header("Location: admin/dashboard.php");
}
else {
header("location: Home.php");
exit();
}
}
else {
print_r("no");
}
}
我正在使用以下逻辑来检查用户是否已登录主页。
session_start();
include_once 'config.php';
if (isset($_SESSION['username'])) {
}
else {
}
我做错了什么,或者我错过了什么阻止我的重定向工作?