警告:無法修改頭文件信息 -/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>
...你的問題是什麼? – naththedeveloper
在任何輸出完成之前,必須設置標題!您將HTML和PHP混合在一起,這不應該由於這個原因而完成。嘗試讀一些關於IPO - http://en.wikipedia.org/wiki/IPO_Model – thpl
如何停止錯誤消息,以便它處理到home.php – user3158691