用session阿,登陆之后就给他一个session

解决方案 »

  1.   

    echo $_SESSION['username']."说道:".$msg;
      

  2.   

    <html>
    <head><title>聊天室</title>
    </head><body bgcolor="#009900" topaling=0><table border=0>
    <form action="input.php" method="post">
    <tr>
      <td bgcolor="#FFFF99" width="565" height="1">
      <spacer type="block" height="1"></td>
      </tr>
      <tr>
      <td>
      大名:<font color=blue>
      
      <?php
        
    echo $_SESSION['username'];
      
      ?></font>
      </td>
      </tr>
      <tr>
      <td>
      <input type="hidden" name="name" value="<? echo $_SESSION['username'];?>">
      内容:<input type="text" name="message" size=55>
      <input type="submit" value="确定">
      </form>
      </td>
      </tr>
      </table>
      <?php
      
    $msg=$_POST['message'];
    $write_file="1.txt";

    if($msg!="")
    { //$name0=$_POST['username'];
       $fp=fopen($write_file,"a+");
       $fw=fwrite($fp,$_SESSION[username]."说道:".$msg);
       fclose($fp);
    }
      
        
      ?></body>
    </html>
    楼上兄弟的话,我试了一下,还是不行的,上面是处理发言的程序,希望高手帮我改一下,在此谢谢了!
    我的思想是把发言的话先写到文本中,最后再读出来,但
    现在的问题就是显示不出来注册时发言人的名字: