<html>
<head><Title>
在线聊天
</title></head>
<!-- frames -->
<frameset rows="70%,*">
<frame src="https://www.jb51.net/article/_b.php" marginwidth="0" marginheight="0" scrolling="yes" FRAMEBORDER="NO" noresize>
<frame src="https://www.jb51.net/article/_a.php" marginwidth="0" marginheight="0" scrolling="no" frameborder="no" noresize>
</frameset>
<body>
</body>
</html>
_a.php
<html>
<title>
聊天室
</title>
<body TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 >
<?php
$person = @$_POST[person];
$msg = @$_POST[message];
if ($person!="" && $msg!=""){
$handle = fopen("msg.txt","r");
$tot = 0;
$oldmsg = array();
while ($content = fgets($handle)){
$oldmsg[] = $content;
++$tot;
}
fclose($handle);
unlink("msg.txt");
$fp = fopen("msg.txt","a+");
$time = date("h:i");
fwrite($fp,"<font color=\"blue\">".$person."</font> in <font color=\"red\">".$time."</font>  says that  <b>".$msg."</b><br>"."\n");
for ($i =0;$i<$tot;++$i){
if ($i>50) break;
fwrite($fp,$oldmsg[$i]);
}
}
?>
<TABLE cellspacing="0" cellpadding="0">
<tr bgcolor="#666666">
<td>
</td></tr>
<tr bgcolor="#FFCC66">
<td ></td>
</tr>
</TABLE>
<table border=0 cellspacing=0 cellpadding=0 bgcolor="#EFEFEF">
<tr bgcolor="#666666">
<td>
<table boder=0 cellspacing=0 cellpadding=0 bgcolor="#EFEFEF">
<tr>
<td valign="top">
<font size="-1" color="#666666">
<table width = "100%" border = "0">
<tr>
<form action="https://www.jb51.net/article/_a.php" method = "post">
<td>
<font size="-1">昵称:</font>
<input type="text" size="12" maxlength="80" value="<?php echo $person;?>">
<br>
<font size="-1"></font>
<textarea type="textarea" rows="9" cols="150" size = 100></textarea>
<input type="submit" value="发言">
</td>
</form>
</tr>
</table>
</font>
</td>
</tr>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
_b.php
复制代码 代码如下:
<html>
<head>
<title>
聊天室
</title>
</head>
<META HTTP-EQUIV=Refresh CONTENT="5; URL=https://www.jb51.net/article/_b.php">
<body bgcolor="#EFEFEF">
<?php
$handle=fopen("msg.txt","r");
//$oldmsg = array();
while ($content = fgets($handle)){
//$oldmsg[] = $content;
//++$tot;
echo $content;
}
?>
</body>
</html>
您可能感兴趣的文章: