标题("位置:");没有在线工作。

时间:2018-05-28 19:11:51

标签: php header location

标题("位置:")无法在线工作,但它适用于localhost。 我也尝试将完整的URI放在标题中,仍然无法正常工作。只需跳过标题("位置:"),但它会写出回声。为什么跳过标题(位置);但打印回声" hellooooo",有人可以帮帮我吗? :)

<?php
  include('header.php');

  session_start();
    if(!isset($_SESSION["login_user"])) {
      header("location:login-form.php");
      echo "hellooooo";
      exit();
    }

?>


<?php
if (isset($_GET['page'])) {
   $p = $_GET['page'];


   switch ($p) {

    case 'job-application':
        include ('job-application.php');
        break;

    case 'company-application':
        include ('company-application.php');
        break;

    case 'edit-text':
        include ('edit-text.php');
        break;

    case 'school-time':
        include ('school-time.php');
        break;

    case 'care-time':
        include ('care-time.php');
        break;

    case 'cleaning-time':
        include ('cleaning-time.php');
        break;

    case 'economy-time':
        include ('economy-time.php');
        break;

    case 'restaurant-time':
        include ('restaurant-time.php');
        break;

    case 'construction-time':
        include ('construction-time.php');
        break;

    case 'retail-time':
        include ('retail-time.php');
        break;

    default:
        include ('job-application.php');
        break;
   }

   } else {

      include ('job-application.php');
}
?>

<?php include('footer.php'); ?>

1 个答案:

答案 0 :(得分:0)

试试这个:

<?php
session_start();
    if(!isset($_SESSION["login_user"])) {
      header("location: http/https://your_site/path_to/login-form.php");
      echo "hellooooo";
      exit();
    }
  include('header.php');

if (isset($_GET['page'])) {
   $p = $_GET['page'];


   switch ($p) {

case 'job-application':
    include ('job-application.php');
    break;

case 'company-application':
    include ('company-application.php');
    break;

case 'edit-text':
    include ('edit-text.php');
    break;

case 'school-time':
    include ('school-time.php');
    break;

case 'care-time':
    include ('care-time.php');
    break;

case 'cleaning-time':
    include ('cleaning-time.php');
    break;

case 'economy-time':
    include ('economy-time.php');
    break;

case 'restaurant-time':
    include ('restaurant-time.php');
    break;

case 'construction-time':
    include ('construction-time.php');
    break;

case 'retail-time':
    include ('retail-time.php');
    break;

default:
    include ('job-application.php');
    break;
   }

   } else {

  include ('job-application.php');
}
?>

<?php include('footer.php'); ?>

我在评论中写了这些笔记。位置:更喜欢绝对URL,所以添加http / https,并在输出任何内容之前运行登录检查到浏览器。 IE浏览器。在登录检查后包括你的header.php。