新浪SAE 用setcookie和header出错

celery121 发布于 2014/02/26 19:17
阅读 1K+
收藏 0
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);  //跳回原页面
  }			
    ?>



加载中
0
南湖船老大
南湖船老大
UTF-8文件,去除BOM即可
c
celery121
试了 不行
0
年轻的比尔
年轻的比尔
楼主解决了吗,我也遇到这个问题啊
返回顶部
顶部