2014-01-13 48 views
-5

警告:无法修改头文件信息 -/home/cs12hs/public_html/COMM2735中已发送的头文件(输出开始于/ home/cs12hs/public_html/COMM2735/login process.php:12) /登录process.php上线47登录时显示此消息

登录过程代码:

<?php session_start();?> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Untitled Document</title> 
<link href="home_start.css" rel="stylesheet" type="text/css" /> 
<link href="login.css" rel="stylesheet" type="text/css" /> 
</head> 

<body> 
<div id="page-container"> 
<?php 


require_once("functions.php"); 

$username = trim($_POST['username']); 

$password = trim($_POST['password']); 

if ($username&&$password){ 
    require_once("db_connect.php"); 
    mysqli_select_db($db_server, $db_database) or 
    die("Couldn't find db"); 

$username = clean_string($db_server, $username); 

$password = clean_string($db_server, $password); 



$query = "SELECT * FROM Userinfo WHERE username='$username'"; 

$result = mysqli_query($db_server, $query); 

if($row = mysqli_fetch_array($result)){ 

$db_username = $row['username']; 

$db_password = $row['password']; 

if($username==$db_username&&salt($password)==$db_password){ 

$_SESSION['username']=$username; 

$_SESSION['logged']="logged"; 
header('Location: home.php'); 
}else{ 
    $message = "<h1>Incorrect password!</h1>"; 
} 

}else{ 
    $message = "<h1>That user does not exist!</h1>" . 
     "Please <a href='login.php'>try again</a>"; 
} 

mysqli_free_result($result); 

mysqli_close($db_server); 


}else{ 

$message = "<h1>Please enter a valid username/password</h1>"; 

} 

//home_start/end only required if submitting to a separate page 

//include_onc("home_start.php"); 
include_once('home_start.php'); 
echo $message; //Place within HTML body 

include_once("home_end.php"); 





?> 
</div> 
</body> 
</html> 
+0

...你的问题是什么? – naththedeveloper

+0

在任何输出完成之前,必须设置标题!您将HTML和PHP混合在一起,这不应该由于这个原因而完成。尝试读一些关于IPO - http://en.wikipedia.org/wiki/IPO_Model – thpl

+0

如何停止错误消息,以便它处理到home.php – user3158691

回答

0

在输出一些HTML之后,您正试图重定向(header('Location: home.php');)。你不应该这样做。如果您需要重定向,您应该在发送任何HTML(或其他输出)之前执行此操作 - 即将其移至您首先执行的操作。

0

header('Location: home.php');

header功能should'nt输出什么...

0

您无法在header()之前向浏览器发送输出。这意味着在重定向代码之前一定不要输出到浏览器。

看到马里奥的answer here ...

故建议使用header()功能,您echo前或显示的东西;在这里,首先使用逻辑,然后使用重定向代码,然后其他HTML(例如<html>, <body>, <link>等...)

0

检查源文件。 <php应从第0位开始。在此之前没有空格。