动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   PHP → 阅读文章

 采用行写方式的聊天程序(之四)

作者来源: 
阅读 数 627 人次 , 2006-4-18 15:50:00 

(接前面部分)

<body leftmargin="0" topmargin="0">
<div align=center>
<br>
<form method="post" action="lt3.php" name="fyq"  target="bforlt3" onsubmit='return(checksays());'>

<input type=hidden name='oldsays' value=''>

姓名: <input type="text" name="username" maxlength="10" >

说:<input type="text" name="saystemp" maxlength="200" size="50" >

<input type="submit" name="send" value="发言" >

<br>


<input type=checkbox name='towhoway' value='1' onclick="document.forms[0].saystemp.focus();">
<a href='#' onMouseOver="window.status='选中本'; return true"  
            onMouseOut="window.status='';        return true" onClick="document.forms[0].towhoway.checked=!(document.forms[0].towhoway.checked);   document.forms[0].saystemp.focus();" title="悄悄话儿悄悄说"><font color=black>私聊</font></a>



<select name='towho' style='font-size:12px' onClick=dj()>
<option value='大家' selected>大家</select>

动作:<select name='addsign' onchange="rc(this.value);" style='font-size:12px'>
     <option value="0" selected>----</option>
     <option value="//热情地向在场的所有人打招呼。">招呼</option>
    </select>

<input type=hidden name="fontsize" size=3>
<input type=hidden name="lineheight" size=3>
<input type=hidden name="oldtitleline" value="0">

<input onclick="javascript:cls();" type="button" value="清屏" style="background-color:FFFFFF;color:000000;border: 1 double">

<input accesskey="a" type="checkbox" name="as" checked onclick='parent.f1.scrollit();document.fyq.saystemp.focus();'>
<a href="#" onclick="Javascript:document.fyq.as.checked=!document.fyq.as.checked;
parent.f1.scrollit();
document.fyq.saystemp.focus();">滚屏</a>  

</form>
<script>
parent.wu();
write();
document.fyq.saystemp.focus();
</script>
</body>
</html>

lt3.php
处理发言信息

<?
session_start();
include("g_fun.php");
f_connectdb();

$query  = "select max(lt_id) as rmaxid from lt_t_content";
$res = mysql_query($query, $dbh);  
$row = mysql_fetch_array($res);
$maxid =  $row["rmaxid"];
if (empty($maxid)) { $maxid = 0; }
$maxid = $maxid + 1;
//增加聊天信息
$query  = "insert into lt_t_content(lt_id,lt_speaker,lt_speaked,lt_secrecy,lt_content,lt_time,lt_face)";
$query .= " values(".$maxid.",'".$username."','".$towho."','1','".$oldsays."',now(),'1')";
$res = mysql_query($query, $dbh);  

//修改最后聊天时间,判断用户是否存在,防止超时被删除
$query  = "select count(*) as rcount from lt_t_online where lt_username = '".$username."'";
$res = mysql_query($query, $dbh);  
$row = mysql_fetch_array($res);
$lcount =  $row["rcount"];
if ($lcount == 0) {
   $query  = "insert into lt_t_online(lt_username,lt_lasttime) values(";
   $query .= "'".$username."',now())";
   $res = mysql_query($query, $dbh);  
}
$query  = "update lt_t_online set lt_lasttime = now(),lt_state = '0' where lt_username = '".$username."'";
$res = mysql_query($query, $dbh);  


//显示聊天记录
$query  = "select lt_id,lt_speaker,lt_face,lt_speaked,lt_time,lt_content from lt_t_content";
$query .= "  where lt_id > ".$chat_hh. " order by lt_time desc";
$res = mysql_query($query, $dbh);  
$chat_hh = $maxid;
$tempi = $maxid;
while ($row = mysql_fetch_array($res)) {  
   ?>
   <script Language=JavaScript1.1>
   var zt="<? echo '0'; ?>";
   var un="<?echo $row['lt_speaker'];?>";
   var tw="<?echo $row['lt_speaked'];?>";
   var sa="<?echo $row['lt_content'];?>";
   parent.f2.nw(zt,un,tw,sa);    //向显示处写入最新的数据.
   </script>
   <?
   $tempi=$row['lt_id'];
}
if ($tempi > $chat_hh) {
   $chat_hh = $tempi;
}

?>  
  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:可以文本显示的公告栏
· 下一篇:php.net新闻拦截!
· Apache服务器高级设置指南(二)
· phpMyAdmin又出了新版本phpMyAdmin-2.2.3-rc1
· 取得随机数
· 用PHP4和PostgreSQL构建一个电子商务应用
· APACHE(6)


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077