首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >登录后,用户不会被重定向到PHP中的特定页面

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

Stack Overflow用户
提问于 2013-04-21 22:29:10
回答 2查看 243关注 0票数 3

在用户登录到数据库后,他应该被重定向到index.php,但我得到的只是警告消息:"Cannot modify header information - headers already by (output started at...“

这是我的输入表单:

代码语言:javascript
复制
<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>

这是我的代码:

代码语言:javascript
复制
<?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");
}?>
EN

回答 2

Stack Overflow用户

发布于 2013-04-21 22:32:34

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

票数 0
EN

Stack Overflow用户

发布于 2013-04-21 23:19:32

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16132190

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档