gpt4 book ai didi

php - 登录用户未重定向到 PHP 中的特定页面后

转载 作者:搜寻专家 更新时间:2023-10-31 22:07:43 24 4
gpt4 key购买 nike

<分区>

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

这是我的输入表单:

<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");
}?>

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com