登录后,用户不会重定向到PHP中的特定页面

登录后,用户不会重定向到PHP中的特定页面,php,sql,Php,Sql,用户登录数据库后,应该将其重定向到index.php,但我得到的只是警告消息: “无法修改标题信息-标题已由发送(输出开始于…” 这是我的输入表格: <form action="login.php" method="post"> <div id="header"><h2 class="sansserif">Login</h2></div> <table> <tr> <td>E

用户登录数据库后,应该将其重定向到index.php,但我得到的只是警告消息: “无法修改标题信息-标题已由发送(输出开始于…”

这是我的输入表格:

<form action="login.php" method="post">
<div id="header"><h2 class="sansserif">Login</h2></div>
<table>

    <tr>
        <td>Enter Username:</td>
        <td> <input type="text" name="username" size="20"></td>
    </tr>

    <tr>
        <td>Enter Password:</td>
        <td><input type="password" name="password" size="20"></td>
    </tr>
    <tr>
         <td><input type="submit" value="Log In"></td>
         <td><a href="signup.html">Sign Up</a></td>
   </tr>
 </table>
</form>

登录
输入用户名:
输入密码:
这是我的代码:

<?php 
include("configuration.php"); 
$username = $_POST["username"];
$password = $_POST["password"];
$match = "select id from $table where username = '".$_POST['username']."'and password =         '".$_POST['password']."';"; 
$qry = mysql_query($match);
$num_rows = mysql_num_rows($qry); 
if ($num_rows <= 0) { 
echo "Sorry, there is no username $username with the specified password.";
echo "Try again";
exit; 
} else {
$_SESSION['user']= $_POST["username"];
header("Location:index.php");
}?>


检查PHP标记前后是否没有空格。我可以在开头看到3个空格,这可能导致“无法修改标题信息”。

首先尝试注释标题()函数检查浏览器上是否有任何输出。如果没有任何输出,请检查您的configuration.php,可能有内容正在被回显或打印。

您在此处有空格/制表符
|作为旁注,您的select查询容易受到SQL注入的影响。检查您的configuration.php文件中
前后是否没有空格。