还是刚刚那个问题
<?php session_start();?><?php//注销登录
if($_GET['action'] == "logout"){
unset($_SESSION['userid']);
unset($_SESSION['username']);
header("Location:login.html");
exit;
}//登录
if(!isset($_POST['submit'])){
exit('非法访问!');
}
$ad_user = htmlspecialchars($_POST['ad_user']);
$ad_pass = MD5($_POST['ad_pass']);//数据库连接
include('conn.php');//检测用户名及密码是否正确
$check_query = mysql_query("select adminid from Admin where ad_user='$ad_user' and ad_pass='$ad_pass' limit 1");
if($result = mysql_fetch_array($check_query)){
//登录成功
$_SESSION['username'] = $ad_user;
$_SESSION['userid'] = $result['adminid'];
header("Location:index.php");
die('Could not connect: ' . mysql_error());
exit;
} else {
header("Location:login.html");
}mysql_close($con)
?>
报错Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/tshareco/public_html/7tshareAdmin/login.php:2) in /home/tshareco/public_html/7tshareAdmin/login.php on line 2Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/tshareco/public_html/7tshareAdmin/login.php:2) in /home/tshareco/public_html/7tshareAdmin/login.php on line 2Warning: Cannot modify header information - headers already sent by (output started at /home/tshareco/public_html/7tshareAdmin/login.php:2) in /home/tshareco/public_html/7tshareAdmin/login.php on line 30
Could not connect: 

解决方案 »

  1.   

    <?php session_start();?>前面不能有空格额,而且不能有bom头。
    把你的文件保存为utf-8无bom的编码
      

  2.   

    <?php  这个开始符在第一行顶格写。  你上面可能空了一行或是前面有空格。 
      

  3.   

    现在好了点<?php session_start();?><?php//注销登录
    if($_GET['action'] == "logout"){
    unset($_SESSION['userid']);
    unset($_SESSION['username']);
    header("Location:login.html");
    exit;
    }//登录
    if(!isset($_POST['submit'])){
    exit('非法访问!');
    }
    $ad_user = htmlspecialchars($_POST['ad_user']);
    $ad_pass = MD5($_POST['ad_pass']);//数据库连接
    include('conn.php');//检测用户名及密码是否正确
    $check_query = mysql_query("select adminid from Admin where ad_user='$ad_user' and ad_pass='$ad_pass' limit 1");
    if($result = mysql_fetch_array($check_query)){
    //登录成功
    $_SESSION['username'] = $ad_user;
    $_SESSION['userid'] = $result['adminid'];
    header("Location:index.php");
    die('Could not connect: ' . mysql_error());
    exit;
    } else {
    header("Location:login.html");
    }mysql_close($con)
    ?>报错Warning: Cannot modify header information - headers already sent by (output started at /home/tshareco/public_html/7tshareAdmin/login.php:3) in /home/tshareco/public_html/7tshareAdmin/login.php on line 29
    Could not connect: 
      

  4.   


    因为你前面已经用了session_start,再使用header函数的话会提示header已经发送的错误。
    解决方法可以用其他方式的页面转向
      

  5.   


    <?php 
    session_start();  //<?php       这行注释掉。都是php代码。多余了。试试看//注销登录
    if($_GET['action'] == "logout"){
    unset($_SESSION['userid']);
    unset($_SESSION['username']);
    header("Location:login.html");
    exit;
    }//登录
    if(!isset($_POST['submit'])){
    exit('非法访问!');
    }
    $ad_user = htmlspecialchars($_POST['ad_user']);
    $ad_pass = MD5($_POST['ad_pass']);//数据库连接
    include('conn.php');//检测用户名及密码是否正确
    $check_query = mysql_query("select adminid from Admin where ad_user='$ad_user' and ad_pass='$ad_pass' limit 1");
    if($result = mysql_fetch_array($check_query)){
    //登录成功
    $_SESSION['username'] = $ad_user;
    $_SESSION['userid'] = $result['adminid'];
    header("Location:index.php");
    die('Could not connect: ' . mysql_error());
    exit;
    } else {
    header("Location:login.html");
    }mysql_close($con)
    ?>试试看