gpt4 book ai didi

php header 方法不重定向

转载 作者:行者123 更新时间:2023-11-29 05:32:07 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
PHP 5.3 does not display error messages
Headers already sent by PHP

我有一个 main.php 文件。它加载我的页眉、正文和页 footer 分。 body 部分是灵活的。在我的索引页面中,站点决定事件页面,因此在主文件中,事件页面主体方法有效。在登录页面中,我检查用户,如果它有效,我想重定向到另一个页面。问题出现在这种情况下。

索引.php:

if(isset($_GET["page"]))
{

$jsPages.="\n\t<script src='pages/".$_GET["page"]."/resources/".$_GET['page'].".js' type='text/javascript' charset='utf-8'></script>";
$cssPages.="\n\t<link rel='stylesheet' href='pages/".$_GET['page']."/resources/".$_GET['page'].".css' type='text/css' media='screen' title='no title' charset='utf-8'/>";
include("pages/". $_GET["page"] ."/_index.php");
}
include("template/$Template/_index.php");

_index.php(主)

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
</head>
<body">
<div ><?php userpanel(); ?></div>
<div id="header"><?php pageHeader(); ?></div>
<div id="horiz-menu" class="splitmenu"><?php horizmenu();?></div>
<div id="sub-menu"></div>
<?php body();?>
<div id="bottom-menu"></div>
<div id="footer"><?php footer();?></div>
</body>
</html>
<?php

登录.php:

<?php
function body(){

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (!$_POST["username"] || !$_POST["password"])
{
die("You need to provide a username and password.");
}

// username and password sent from Form
$myusername=addslashes($_POST['username']);
$mypassword=addslashes($_POST['password']);

$sql="SELECT id FROM members WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
session_register("myusername");
$_SESSION['login_user']=$myusername;
header("location: pages/welcome/_index.php");
exit();
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
<form action="" method="post">
<label>UserName :</label>
<input type="text" name="username"/><br />
<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Submit "/><br />
</form>
<?php }

我搜索了它,但找不到任何答案。我该如何解决或问题是什么?

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