错误提示:
SAE_Warning: Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/345/leank/1/bbs/login.php:15) in bbs/login.php on line 9
SAE_Warning: Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/345/leank/1/bbs/login.php:15) in bbs/login.php on line 10
SAE_Warning: Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/345/leank/1/bbs/login.php:15) in bbs/login.php on line 28
SAE_Warning: Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/345/leank/1/bbs/login.php:15) in bbs/login.php on line 29
大致的代码:
<?php
/*
* 未完成内容 : 添加判断的url中log?= "" 的if语句,来判断用户是登陆还是退出
*添加一个判断是否已经登陆的if语句
*
*/
include("conn.php");
function clearcookies(){
setCookie('username','',time()-3600);
setCookie('logset','',time()-3600);
}
?>
<?php
if ($_POST['loginsubmit']) //检查是否提交
{
clearcookies();
$sql = "SELECT * FROM user WHERE username = '$_POST[username]'";
$query = mysql_query($sql);
$userinfo = mysql_fetch_array($query);
if ($_POST[password] != "" & $_POST[username] != "") //检查用户名密码是否填写
{
if ($userinfo['password'] == $_POST['password'] ) //在SQL中检查用户名密码是否正确
{
$username = $_POST[username];
setcookie('username','$username',time()+31536000,'/');
setcookie('logset','ok',time()+31536000,'/');
echo "<meta http-equiv=refresh content=0;url=index.php?foo=$_POST[username]>";
}
else
{
echo "登录失败!";
echo "请检查您的用户名或密码是否都填写正确";
}
}
else
{
echo "登录失败!";
echo "请检查您的用户名或密码是否为空";
}
}
?>
处错误的大致是这个位置:
setcookie('username','$username',time()+31536000,'/');
setcookie('logset','ok',time()+31536000,'/');