您现在的位置: 军旅同心 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 文章正文
用PHP和ACCESS写聊天室(一)
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 14:36:23
INDEX.PHP
代码如下!

<?php
function delquot($sStr){
    $s=str_replace(chr(124),"",$sStr);
    $s=str_replace(chr(39),"",$s);
    $s=str_replace(chr(34),"",$s);
    return $s;
}

if ($cmdYes=="进   入"){
    $sUserName=htmlspecialchars(trim(delquot($sUserName)));
    if ($sUserName=="superldz" && $sPass="superldz"){
        $sUserID=1;
        include("chtmain.php3");
        exit();
    }
    else{
        $ConnID=@odbc_connect("jtfcht","admin","");
        if ($ConnID){
            $result=@odbc_exec($ConnID,"SELECT UserID,UserName,PassWord,RoomID,Sex FROM User WHERE UserName='".$sUserName."'");
            if (@odbc_fetch_into($result,0,&$rArr)){
                $sUserID=$rArr[0];
                if ($rArr[2]==$sPass){
                    if ($rArr[3]==0){
                        @odbc_exec($ConnID,"UPDATE User SET RoomID=1,LstDate='".date("Y.m.d")."',ToID=0,ToName='大家',Secret=False,FirstTime=True,LstTime=".time()." WHERE UserID=".$sUserID);
                        if ($rArr[4])
                            @odbc_exec($ConnID,"INSERT INTO ChtCont (sIDFrom, sNameFrom, sIPFrom, sIDTo, sNameTo, sTime, sCont, bSecret, RoomID) VALUES (".$rArr[0].", '".$rArr[1]."', '".getenv("REMOTE_ADDR")."', 0, '大家', '".date("H:i:s")."', '<font color=gray>【系统消息】欢迎<font color=#FF9933>".$rArr[1]."</font>来到了这个聊天室</font>', False, 1)");
                        else
                            @odbc_exec($ConnID,"INSERT INTO ChtCont (sIDFrom, sNameFrom, sIPFrom, sIDTo, sNameTo, sTime, sCont, bSecret, RoomID) VALUES (".$rArr[0].", '".$rArr[1]."', '".getenv("REMOTE_ADDR")."', 0, '大家', '".date("H:i:s")."', '<font color=gray>【系统消息】欢迎<font color=#3399FF>".$rArr[1]."</font>来到了这个聊天室</font>', False, 1)");
                        include("chtmain.php3");
                        exit();
                    }
                    else $sErrText="登录出错,<font color="red">已经有人用这个名字登录了</font>!";
                }
                else $sErrText="登录出错,<font color="red">口令不正确</font>!";
            }
            else $sErrText="登录出错,<font color="red">用户没注册</font>!";
            @odbc_close($ConnID);
        }
        else $sErrText="<font color="red">系统故障</font>,暂时无法登录";
    }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>温酒吧聊天室</title>
<script language="JavaScript">
<!--
function NameGotFocus( ) {
    document.frmLogin.sUserName.focus();
}

function CheckValid() {
    if (document.frmLogin.sUserName.value == "") {
        alert( "请输入昵称。");
        document.frmLogin.sUserName.focus();
        return false;
    }
    if (document.frmLogin.sPass.value == "") {
        alert( "请输入口令。");
        document.frmLogin.sPass.focus();
        return false;
    }
    return true;
}
//-->
</script>
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body onload="NameGotFocus()">
<p>&nbsp;</p>
<table align="center" border="0" cellPadding="0" cellSpacing="0" width="90%">
    <tr>
        <td rowspan="3" align="right" width="30%" valign="top"><img alt="Cht" src="cht.jpg" WIDTH="192" HEIGHT="384"></td>
        <td height="170" align="middle">
            <embed src="logo.swf" width="300" height="70"></embed>
            <p>本页永久域名:<a href="http://jtf.126.com/">http://jtf.126.com/</a>
        </td>
    </tr>
    <tr>
        <td align="middle">
        <table align="center" border="0" cellPadding="0" cellSpacing="0" width="80%">
            <tr>
                <td align="center">
                    <div align="center"><center><table border="0" width="100%">
                        <tr>
                            <td><hr size="1" color="#800000"></td>
                        </tr>
<?php
if ($cmdYes=="进   入"){
?>
                        <tr>
                            <td align="center"><?php echo $sErrText; ?></td>
                        </tr>
                        <tr>
                            <td><hr size="1" color="#800000"></td>
                     &nb

[1] [2] [3] 下一页


 
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 管理登录 |