在我生命中无法获得标头重定向或java重定向在此lock.php中工作
<?php
include 'config.php' ;
session_start();
$user_check=$_SESSION['login_user'];
$ses_sql=mysqli_query($db,"select username from users where username='$user_check' ");
$row=mysqli_fetch_array($ses_sql,MYSQLI_ASSOC); //confirm username from users table
$login_session=$row['username'];
if ($login_session ==""){
// echo "the variable is empty"; //when i check this works here.
//header ("Location: login.php"); //redirect to login -tried this, fail
echo "<script> location.href='login.php'; </script>"; // tried this, fail
exit(); //stop execution of any further script
}
?>
答案 0 :(得分:1)
我建议:
if (empty($login_session)) { // You're checking for any empty/null value
header("Location: login.php");
exit; // Per php docs, header does not halt execution
}
您的代码有问题。