新浪SAE 用setcookie和header出错? 400 报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

新浪SAE 用setcookie和header出错? 400 报错

爱吃鱼的程序员 2020-06-01 10:20:12 119

新浪SAE 用setcookie和header出错? 400 报错 Warning : Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/271/lectureland/2/user_info/dbtools.inc.php:1) in user_info/checkpwd.php  on line  44

Warning : Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/271/lectureland/2/user_info/dbtools.inc.php:1) in user_info/checkpwd.php  on line  45

Warning : Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/271/lectureland/2/user_info/dbtools.inc.php:1) in user_info/checkpwd.php  on line  46

Warning : Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/271/lectureland/2/user_info/dbtools.inc.php:1) in user_info/checkpwd.php  on line  47

Warning : Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/271/lectureland/2/user_info/dbtools.inc.php:1) in user_info/checkpwd.php  on line  48

Warning : Cannot modify header information - headers already sent by (output started at /data1/www/htdocs/271/lectureland/2/user_info/dbtools.inc.php:1) in user_info/checkpwd.php  on line  58

<?php require_once("dbtools.inc.php"); $database = "app_lectureland"; //获取窗体数据 $ret = $_POST["ret"]; $account = $_POST["account"]; 	 $password = $_POST["password"]; //创建数据连接 $link = create_connection();

//检查帐号密码是否正确 $sql = "SELECT * FROM users Where account = '$account' AND password = '$password' "; $result = execute_sql($database, $sql, $link);

//如果帐号密码错误 if (mysql_num_rows($result) == 0) { //释放 $result 占用的内存 mysql_free_result($result);

//关闭数据连接	
mysql_close($link);		
	
//显示消息要求用户输入正确的帐号密码
echo "<script type='text/javascript'>";
echo "alert('帐号密码错误,请查明后再登录');";
echo "history.back();";
echo "</script>";

}

//如果帐号密码正确 else { //获取 id 字段 $id = mysql_result($result,0,"user_id"); $type = mysql_result($result,0,"user_type"); $username = mysql_result($result,0,"name"); $account = mysql_result($result,0,"account"); //释放 $result 占用的内存 mysql_free_result($result); //关闭数据连接 mysql_close($link); //将用户数据加入 cookies setcookie("user_id", $id,0,'/'); setcookie("passed", "TRUE",0,'/'); setcookie("name", $username,0,'/'); setcookie("user_type", $type,0,'/'); setcookie("account", $account,0,'/'); if(empty($ret)){ if($type == "user") { $ret='user/index.php'; } else{ $ret='admins/course.php'; } } header("location:" . $ret); //跳回原页面 } ?>



SQL PHP
分享到
取消 提交回答
全部回答(1)
  • 爱吃鱼的程序员
    2020-06-01 10:20:14

    UTF-8文件,去除BOM即可######试了 不行######楼主解决了吗,我也遇到这个问题啊

    0 0
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题