重複の可能性:
「警告: ヘッダー情報を変更できません - ヘッダーは既に送信されています」エラー
Headers already sent by PHP
問題は空白が原因であると述べている他の多くのサイトを見てきました。PHPスクリプトの終了後、PHPスクリプトの開始前に空白を残さないため、それが問題だとは思いません。ここに完全なエラーがあります
: ヘッダー情報を変更できません - admin/login.php 行 22 の (/admin/login.php:19 で出力が開始された) によって既に送信されたヘッダー
これが私のコードです:
<?php
require_once("../../includes/database.php");
require_once("../../includes/session.php");
require_once("../../includes/user.php");
if($session->is_logged_in())
{
header("Location:index.php");
}
if(isset($_POST['submit']))
{
$username = trim($_POST['username']);
$password = trim($_POST['password']);
//Check Databases
$found_user = User::authenticate($username, $password);
$found_user->id = $found_user[0];
if($found_user)
{
$session->login($found_user);
header("Location:index.php");
}
else
{
echo "Username/password combination incorrect.";
}
} else { //form is not submitted
$username = "";
$password = "";
}
?>
<html>
<head>
</head>
<body>
<h1>Photo Gallery</h1>
<div id="main">
<h2>Staff Login</h2>
<form action="login.php" method="post">
<table>
<tr>
<td>Username:</td>
<td>
<input type="text" name="username" maxlength="30" value="" />
</td>
</tr>
<tr>
<td> Password:</td>
<td>
<input type="password" name="password" maxlength="30" value="" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="submit" value"Login" />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<?php if(isset($database))
{
$database->close_connection();
}
?>