搜尋
首頁php教程php手册php简单的在线聊天室程序

php教程简单的在线聊天室程序

index.php

<title>
在线聊天
</title>
<!-- frames -->
<frameset rows="70%,*" border="0">
    <frame name="top" src="_b.php" marginwidth="0" marginheight="0" scrolling="yes" frameborder="NO" noresize>
    <frame name="bottom" src="_a.php" marginwidth="0" marginheight="0" scrolling="no" frameborder="no" noresize>
</frameset>


 


_a.php

 class="brush: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>&nbspin&nbsp<font color="red">".$time."</font>&nbsp&nbsps教程ays that&nbsp&nbsp<b>".$msg."</b><br>"."n");
for ($i =0;$i<$tot;++$i){
    if ($i>50) break;
    fwrite($fp,$oldmsg[$i]);
}
}

<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="left" bgcolor="#666666">
<td height="20">
</td></tr>
<tr bgcolor="#FFCC66">
<td width="1" height="4" ></td>
</tr>
</TABLE>
<table width="100%" border=0 cellspacing=0 cellpadding=0 bgcolor="#EFEFEF">
<tr bgcolor="#666666">
<td align="left">
<table width="100%" height="500" boder=0 cellspacing=0 cellpadding=0 bgcolor="#EFEFEF">
<tr align="left">
<td valign="top">
<font size="-1" color="#666666">
 
<table width = "100%" border = "0">
    <tr>
    <form action="_a.php" method = "post">
        <td align="left">
        <font size="-1">昵称:</font>
        <input type="text" name="person" size="12" maxlength="80" value="<?php echo $person;">
        <br>
        <font size="-1"></font>
        <textarea type="textarea" name="message" 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

 class="brush:php;"><html>
    <head>
        <title>
        聊天室
        </title>
    </head>
    <META HTTP-EQUIV=Refresh CONTENT="5; URL=_b.php">
    <body bgcolor="#EFEFEF">
    <?php
        $handle=fopen("msg.txt","r");
        //$oldmsg = array();
        while ($content = fgets($handle)){
        //$oldmsg[] = $content;
        //++$tot;
            echo $content;
        }
    
    </body>
</html>

永久链接:

转载随意!带上文章地址吧。

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具