欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用PHP和ACCESS写聊天室(九)

程序员文章站 2022-04-28 14:32:38
enterrm.php3 代码如下:
enterrm.php3
代码如下:
<?php
        $connid=@odbc_connect("jtfcht","admin","");
        if ($connid){
                $result=@odbc_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){
                                        $result=@odbc_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){
                                                                $result=@odbc_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 onload="passsetfocus();">
<p> </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> </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");
?>



【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】