可能重复:
PHP 5.3 不显示错误消息
PHP 已发送的标头
我有一个 main.php 文件。它加载我的页眉、正文和页脚部分。身体部分是灵活的。在我的索引页面中,站点决定了活动页面,因此在主文件中,活动页面正文方法有效。在登录页面中,我检查用户,如果它有效,我想重定向到另一个页面。在这种情况下会出现问题。
索引.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 }
我搜索它,但找不到任何答案。我该如何解决它或有什么问题?