首页 > 开发 > PHP > 正文

用PHP和ACCESS写聊天室(九)

2024-05-04 23:01:41
字体:
来源:转载
供稿:网友
enterrm.php3
代码如下:
<?php
        $[email protected]_connect("jtfcht","admin","");
        if ($connid){
                $[email protected]_exec($connid,"select password,lsttime,roomid,refrate from user where userid=".$id);
                if (@odbc_fetch_into($result,0,&$rarr)){
                        $sroomid=$rarr[2];
                        $srefrate=(int)$rarr[3];
                        if ($srefrate<2) $srefrate=2;
                        if (($rarr[0]==$ps) && ($rarr[1]>=(time()-1800))){
                                $snewroomid=substr($selroom,2);
                                if ($snewroomid!=$sroomid){
                                        $[email protected]_exec($connid,"select password from room where roomid=".$snewroomid);
                                        if (@odbc_fetch_into($result,0,&$rarr)){
                                                if ((strlen(trim($rarr[0]))==0) || ($rarr[0]==$spass)){
                                                        @odbc_exec($connid,"update user set roomid=".$snewroomid.",toid=0,toname='大家' where userid=".$id);
                                                        if ((int)$sroomid!=1){
                                                                $[email protected]_exec($connid,"select count(userid) from user where roomid=".$sroomid);
                                                                @odbc_fetch_into($result,0,&$rarr);
                                                                if ($rarr[0]==0) @odbc_exec($connid,"delete * from room where roomid=".$sroomid);
                                                        }
                                                }
                                                else{
?>
<html>
<head>
<title>输入房间口令</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="main.css" type="text/css">
<script language="javascript">
<!--

function passsetfocus( ) {
        document.frmentersm.spass.focus();
}

//-->
</script>
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body >
<p>&nbsp;</p>
<p align="center"><font color="#996666">输入房间口令</font></p>
<form name="frmentersm" action="enterrm.php3" method="post">
<table width="100%" border="0" align="center">
        <tr>
                <td colspan="2"><input type="hidden" name="selroom" value="<?php echo $selroom; ?>"><input type="hidden" name="id" value="<?php echo $id; ?>"><input type="hidden" name="ps" value="<?php echo $ps; ?>"></td>
        </tr>
        <tr>
                <td width="40%" align="right">口令:</td>
                <td width="60%"><input type="password" name="spass" maxlength="10" size="8"></td>
        </tr>
        <tr>
                <td colspan="2" align="center"><input type="submit" name="cmdyes" value="进入"></td>
        </tr>
</table>
</form>
<p align="center">按<a href="room.php3?id=<?php echo $id; ?>&ps=<?php echo $ps; ?>&at=<?php echo time(); ?>">这里</a>放弃</p>
</body>
</html>
<?php
                                                        exit();
                                                }
                                        }
                                        else{
?>
<html>
<head>
<title>加入房间出错</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body>
<p>&nbsp;</p>
<p align="center">这个房间已经被拆了!</p>
<p align="center">按<a href="room.php3?id=<?php echo $id; ?>&ps=<?php echo $ps; ?>&at=<?php echo time(); ?>">这里</a>返回</p>
</body>
</html>
<?php
                                                exit();
                                        }
                                }
                        }
                        else echo "<html><head><meta http-equiv='content-type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
                }
                else echo "<html><head><meta http-equiv='content-type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
                @odbc_close($connid);
        }
        else echo "<html><head><meta http-equiv='content-type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
        include("room.php3");
?>
  • 本文来源于网页设计爱好者web开发社区http://www.html.org.cn收集整理,欢迎访问。
  • 发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表