2017-04-07 90 views
-1

IK这是一个愚蠢的,但我无法找到任何解决方案,我的代码是这样的,无论我添加/更改什么代码,它只是不会budge ...(注意即时通讯不使用普通的PHP,使用朋友的版本,是的,是好的,花花公子)无法修改标题信息错误?

<?php 
include($_SERVER['DOCUMENT_ROOT'].'/phpAlphaDB/core.php'); 
?> 

<html> 
<head> 
<link rel="icon" type="image/png" href="../logo.png"> 
    <title> Xenoz Web - Users </title> 
    <link rel="stylesheet" type="text/css" href="../css/style.php" /> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"> 
</head> 
<?php 
    if ($role==0) { 
    header('Location: http://xenozweb.tk/index.php'); 
} else { 
     echo '<script>alert("Hello, '.$username.'. Welcome to the userlist...");</script>'; 
    } 
    ?> 

<body> 
    <div class="navigation"> 
     <a href="index.php"><div class="navitem"> Home </div></a>  
     <a href="/register/"><div class="navitem"> Register </div></a> 
     <a href="/login/"><div class="navitem"> Login </div></a> 
     <a href="https://stackoverflow.com/users/"><div class="navitem"> Users </div></a> 
     <a href="/jukebox/"><div class="navitem"> Jukebox </div></a> 
     </div> 
    </div> 
    <div class="pagecontent"> 
     <div class="userblock"> 
     <?php 
      $results = db_read('xenozweb-users', '', 'username'); 
      foreach ($results as $result) { 
      $u_name = db_column($result, 0); 
      echo '<div class="users">',$u_name,'</div>'; 
      } 
      ?> 
     </div> 
    </div> 
</body> 
</html> 
+0

在[PHP:header](https://secure.php.net/manual/en/function.header.php)中列出的标题之前不会出现任何输出 – FD3

回答

0

您在设置标题之前返回部分响应。在将响应发送回浏览器之前,必须先发送标题。

尝试header('Location: ')函数调用移动到顶部<?php外壳就像这样:

<?php 
    include($_SERVER['DOCUMENT_ROOT'].'/phpAlphaDB/core.php'); 

    if ($role==0) { 
     header('Location: http://xenozweb.tk/index.php'); 
    } 
?> 

<html> 
<head> 
<link rel="icon" type="image/png" href="../logo.png"> 
<title> Xenoz Web - Users </title> 
<link rel="stylesheet" type="text/css" href="../css/style.php" /> 
<meta http-equiv="content-type" content="text/html; charset=utf-8"> 

<?php 
    if ($role != 0) { 
     echo '<script>alert("Hello, '.$username.'. Welcome to the userlist...");</script>'; 
    } 
?> 

</head> 
<body> 
+0

tyvm!在10分钟内我会接受答案 – n0b0y

0

你已经发送数据到浏览器。一旦您已经开始发送数据有效载荷,您就无法正确发送header()信息。

相关问题