zoukankan      html  css  js  c++  java
  • php写的简易聊天室

    简介:这是php写的简易聊天室的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。

    class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=337299' scrolling='no'>

    index.php

    <html>
    <head><Title>
    在线聊天
    </title></head>
    <!-- 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>

    <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>&nbspin&nbsp<font color=\"red\">".$time."</font>&nbsp&nbspsays 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

    <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>


    爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

    http://biancheng.dnbcw.info/php/337299.html pageNo:9
  • 相关阅读:
    python新建以时间命名的目录
    selenium跳过https的问题
    selenium修改控件属性
    selenium遍历控件集合
    知识库系统confluence5.8.10 安装与破解
    python3 遍历文件
    mysql更新密码为空
    CentOS7下安装配置vncserver
    Centos7搭建php+mysql环境(整理篇)
    centos7上安装与配置Tomcat7(整理篇)
  • 原文地址:https://www.cnblogs.com/ooooo/p/2247035.html
Copyright © 2011-2022 走看看