<?php
session_start();
?><html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function checklogin()
{
 if((login.nickname.value!="") && (login.password.value!=""))
    //如果昵称或密码均不为空则返回真值
return true;
  else
     {
  //如果昵称或密码为空,则显示警告信息
  alert("昵称或密码不能为空!");
  return false;
 }
}
</script>
<body><center>
  <h2>飞雪聊天室</h2>  
  <form action="login.php" method="post" name="login" onSubmit="return checklogin()"> 
<table width="100%"  border="0" align="left">
  <tr>
    <td width="50%" align="right">昵称:</td>
    <td width="50%"><input name="nickname" size="10"></td>
  </tr>
  <tr>
    <td width="50%" align="right">密码:</td>
    <td width="50%"><input name="password" size="10" type="password"></td>
  </tr>
  <tr align="center">
    <td height="28" colspan="2"><input name="submit" type="submit" value="登录"></td>
  </tr>
  <tr align="center">
    <td height="46" colspan="2"><hr>      <font color="#3300cc">首次登录时<br>
      将自动注册</font></td>
  </tr>
</table>
  </form>
</center>
</body>
</html>
下面是login.php<?
if(isset($UserName))
{
 exit;
}?>

解决方案 »

  1.   

    login.php最上面是不是有个空行,你顶格写
      

  2.   

    你的login.php的代码没有原样贴出来吧?
    里边的session_start前边检查一下是否有输出?空格或者空行什么的?
    有点晕……
      

  3.   

    确认session_start();前面没有任何东西
    确认session_start()的页没有包含在别的页里
      

  4.   

    提示:“Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by ... ” 跟你的php.ini的session.auto_start = 1
    的配置有关,如果session.auto_start = 1则
    <?
    if(isset($UserName))
    {
     exit;
    }?>
    是正确的,否则就要写session_start();