header()、session_start();
等之前不能有任何输出,包括空格。

解决方案 »

  1.   

    header()、session_start();还有setcookie
      

  2.   


    <?
       require("config.php");
        if($LoginName==""){echo"<meta http-equiv=refresh content=7;URL='javascript:history.back(1);'><br><br><br><br><font size=3>请输入<font color=ff0000>用户名</font></font><br><a href=javascript:history.go(-1);>返回</a><br><br><br>若未注册请点<a href=reg.php>[这里注册]</a>";exit;}
    if($Password==""){echo"<meta http-equiv=refresh content=5;URL='javascript:history.back(1);'><br><br><br><br><font size=3>请输入<font color=ff0000>用户密码</font></font><br><a href=javascript:history.go(-1);>返回</a>";exit;}

        $user_array=file($user_file);
    $user_all=count($user_array);

    for($i=1; $i<$user_all; $i++) {
    list($name,$pwd,$email,$tel)=explode("|",$user_array[$i]);
    if ($LoginName == $name){if ($Password != $pwd){echo"<br><br><br><br><font size=3 color=ff0000>用户名与密码不匹配!</font>";exit;}break;}
    if (($LoginName != $name) and ($i==$user_all-1)){echo"<br><br><br><br><font size=3>用户“<font color=ff0000>{$LoginName}</font>”不存在!</font>";exit;}
    }setcookie("username",$LoginName,0);
    setcookie("userpwd",$Password,0);echo $username; echo "登陆成功!";
    ?>这是整个文件代码,大家帮看看问题出在哪里?