Php 即使删除了空白,标题也不会重定向

Php 即使删除了空白,标题也不会重定向,php,Php,我在代码中包含了一个header(),但它不会重定向。我知道在发送header()之前不应该有任何空格,但它仍然不起作用。有人能帮忙吗。提前谢谢 <?php session_start(); if(isset($_SESSION["owner"])){ header("Location:index.php"); exit(); } ?> <?php require_once("includes/connection.ph

我在代码中包含了一个header(),但它不会重定向。我知道在发送header()之前不应该有任何空格,但它仍然不起作用。有人能帮忙吗。提前谢谢

<?php 
    session_start();
    if(isset($_SESSION["owner"])){
        header("Location:index.php");
        exit();
    }
?>
<?php
require_once("includes/connection.php");
if(isset($_POST["username"]) && isset($_POST["password"])){
$owner = $_POST["username"];
$password = $_POST["password"];
$query = "SELECT id FROM users WHERE username = '$owner' AND password ='$password' LIMIT 1";
 $sql = mysql_query($query,$connection);
 $existCount = mysql_num_rows($sql);
        if($existCount == 1){   
        while($row = mysql_fetch_array($sql)){
        $id = $row["id"];
        }
        $_SESSION["id"] =$id;
        $_SESSION["owner"] = $owner; 
        $_SESSION["password"] =$password;
        header("Location:list.php");
        exit();
        }else{
        header("Location:login.php");
        exit();
        }
}
require_once("includes/header.php");?>
<div class="cBoth"></div>
<div id="sep"></div>

<div class="Calign">
<div id="formcontent">

<div class="flotr">
 <h2>Learn More</h2> 
 <p class="widthis">Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.</p>
</div><!-- end of flotr div text --->

<div class="flotr">
   <fieldset class="spacing">
   <form method="post" action="admin/formProc/formproc.php">
     <h2>New to MaalHouse?</h2>
     <p class="widthis">A Maalhouse account is required to continue.</p> 
     <p class="formsp">Name</p>
     <p><label><input type="text" name="username" height="15px"/><label></p>
     <p class="formsp">Email</p>
     <p><label><input type="text" name="email"/><label></p>
     <p class="formsp">Re-email</p>
     <p><label><input type="text" name="reemail"/><label></p>
     <p class="formsp">Password</p> 
     <p><label><input type="password" name="password"/><label></p>
     <p class="formsp">Re-password</p>
     <p><label><input type="password" name="repassword"/><label></p>
     <p class="formsp"><label><input type="submit" name="newuser" value="SING ME UP"/><label></p>
   </form>
  </fieldset>
</div><!-- end of flotr div sign up--->




<div class="flotl">
   <fieldset class="spacing">
   <form method="post" action="login.php">
   <h2>New to MaalHouse?</h2>
   <p class="widthis">A Maalhouse account is required to continue.</p> 
   <p class="formsp">Username</p>
   <p><input type="text" name="username"/></p>
   <p class="formsp">Password</p>
   <p><input type="password" name="password"/></p>
   <p></p>
   <p class="formsp"><label><input type="submit" name="login" value="Login"/><label></p>   
   </form>
   </fieldset>
</div><!-- end of flotl div login--->


 </div>
</div>


<div class="cBoth"><!-- clear Both--></div> 
<?php require_once("includes/footer.php"); ?> 


PHP的结束块和开始块之间有一条新线:

?>
<?php
?>

您确定已设置
$\u会话['owner']
?尝试将
if
语句更改为
if(true){
以测试它;如果它重定向-问题是会话变量未设置(或为空)。请定义“不工作”。如果
$\u session['owner',则位置应为完整url,而不仅仅是文件名
是否已设置?是否在开始时使用BOM表保存文件?请检查编辑器中的文档,确保未设置。