当前位置: 首页 > 图文教程 > 网络编程 > PHP > 采用行写方式的聊天程序(之四)

PHP
新手入门:学习掌握动态网页PHP的编程语句
PHP建设论坛:Discuz!论坛快速架设指南
理解动态网页技术PHP与数组的应用
PHP初学:实例详细学习PHP的简单语法
PHP实例:PHP生成带有雪花背景的网站验证码
PHP网站开发中关于包含路径问题的解决方案
用PHP实现网页开发中的翻页跳转
用PHP程序实现随机广告图片显示
如何使PHP文件与HTML代码更好的分离
PHP关于代码转换问题比较完善的解决办法
新手如何使用PHP创建RSS阅读器
用PHP程序为自己网站打造一个搜索引擎
PHP实现文件安全下载的程序
快速掌握MySQL数据库中SELECT语句
用javascript+php随机显示图片
论Web 2.0 时代PHP的地位
用动态网页技术PHP打造个人网站全攻略
问题解决:无法载入MYSQL扩展,请检查PHP配置
新手入门:PHP网站开发中常见问题汇总
用PHP程序实现删除目录的三种方法实例

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 25 ::
收藏到网摘: n/a

  (接前面部分)

<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