开发者社区> 问答> 正文

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

新浪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); //跳回原页面 } ?>



展开
收起
爱吃鱼的程序员 2020-06-01 10:20:12 512 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

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

    2020-06-01 10:20:14
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
SAE 引领应用步入 Serverless 全托管新时代 立即下载
Serverless时代下大规模微服务应用运维的最佳实践 立即下载
云效携手SAE助力掌讯科技持续降本提效 立即下载