Write a chat room with PHP and Access (ix)
Last Update:2017-02-28
Source: Internet
Author: User
Enterrm.php3
The code is as follows:
<?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= ' everyone ' 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{
?>
<title> Enter room password </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" >
<body >
<p> </p>
<p align= "center" ><font color= "#996666" > Enter room password </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;?> "& Gt;</td>
</tr>
<tr>
<TD width= "40%" align= "right" > Password:</td>
<TD width= "60%" ><input type= "password" name= "Spass" maxlength= "ten" size= "8" ></td>
</tr>
<tr>
<TD colspan= "2" align= "center" ><input type= "Submit" Name= "Cmdyes" value= "enter" ></td>
</tr>
</table>
</form>
<p align= "center" > Press <a href= "room.php3?id=<?php echo $id; >&ps=<?php echo $ps;?>&at=< ? PHP echo Time ();?> "> Here </a> give up </p>
</body>
<?php
Exit ();
}
}
else{
?>
<title> Join Room Error </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<link rel= "stylesheet" href= "Main.css" type= "Text/css" >
<body>
<p> </p>
<p align= "center" > This room has been demolished! </p>
<p align= "center" > Press <a href= "room.php3?id=<?php echo $id; >&ps=<?php echo $ps;?>&at=< ? PHP echo Time ();?> "> Here </a> return </p>
</body>
<?php
Exit ();
}
}
}
else echo "}
else echo "@odbc_close ($ConnID);
}
else echo "Include ("room.php3");
?>