我有一个php登录功能。当我尝试使用正确的用户登录时,它会显示如下错误:
警告:无法修改标头信息 - 第 150 行 /home/hapshou1/public_html/index.php 中的标头(输出开始于 /home/hapshou1/public_html/index.php:15)
-
include "config.php";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
function antiinjection($data)
{
$filter_sql = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($data,ENT_QUOTES))));
return $filter_sql;
}
$username = antiinjection($_POST['username']);
$pass = antiinjection($_POST['password']);
$login=mysql_query("SELECT username, password FROM user WHERE (username='$username' OR email='$username') AND password='$pass'");
$found=mysql_num_rows($login);
$r=mysql_fetch_array($login);
if
((!empty($username)) &&
(!empty($pass)))
{
if ($found > 0)
{
session_register("username");
session_register("password");
$_SESSION[username] = $r[username];
$_SESSION[password] = $r[password];
date_default_timezone_set("Asia/Jakarta");
$date_log = date("j-F-Y, G:i ");
mysql_query("update user set status='online', date_logged_in='$date_log' WHERE username='$_SESSION[username]'");
header('location:home');
}
else
{
echo '<div class="error_log">
<p>Wrong username or password. Please try again.</p>
</div>';
}
}
else
{
echo '
<div class="error_log">
<p>Username and password are required.</p>
</div>
';
}
}
我的代码有什么问题?