脚本宝典收集整理的这篇文章主要介绍了用PHP和ACCESS写聊天室(四),脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
代码如下:
<?
PHP &nbs
p; $ConnID=@odbc_connect("jt
fcht","admin","");
if ($ConnID){
@odbc_exec($ConnID,"DELETE *
From Room WHERE (RoomID Not IN (SELECT DISTINCT RoomID F
rom User)) AND RoomID<>1");
$result=@odbc_exec($ConnID,"SELECT PassWord,LstTime,RoomID,RefRate FROM User WHERE UserID=".$id);
if (@odbc_fetch_into($result,&$rArr)){
$sRoomID=$rArr[2];
$sRefRate=(int)$rArr[3];
if ($sRefRate<2) $sRefRate=2;
if (($id
=="1" && $ps=="su
PErldz") || (($rArr[0]==$ps) && ($rArr[1]>=(time()-1800)))){
if ($bPost=="1"){
$sDelRoom=s
ubstr($sDelRoom,2);
if ($sDelRoom=="1") $bCanDel=false;
else $bCanDel=true;
if ($id!="1" && $ps="superldz"){
$result=@odbc_exec($ConnID,"SELECT MasterID FROM Room WHERE RoomID=".$sDelRoom);
if (@odbc_fetch_into($result,&$rArr)){
if ($rArr[0]!=$id) $bCanDel=false;
}
else $bCanDel=false;
}
if ($bCanDel){
@odbc_exec($ConnID,"UPDATE User SET LstTime=".time()." WHERE RoomID=".$sDelRoom." AND UserID=".$id);
@odbc_exec($ConnID,"UPDATE User SET RoomID=1 WHERE RoomID=".$sDelRoom);
@odbc_exec($ConnID,"DELETE * FROM Room WHERE RoomID=".$sDelRoom);
$sRoomID="1";
}
}
?>
<ht
ML>
<head>
<
Meta http-equiv="Content
-type" content="text/html; charset=gb2312">
<t
ITle>房间</title>
<link rel="stylesheet"
href="
;main.css" type="text/css">
<
Meta http-equiv="refresh" content="<?
PHP echo (((int)($sRefRate))*8); ?>;url=room.
PHP3?id=<?
PHP echo $id ?>&ps=<?
PHP echo $ps; ?>&at=<?
PHP echo time(); ?>">
<script language="JavaScript">
<!--
function CheckValid() {
document.frmInRoom.selRoom.value = document.frmRoom.selRoom.value;
return true;
}
function AlertIt() {
document.frmDelRoom.sDelRoom.value = document.frmRoom.selRoom.value;
return confirm("你真的要拆了这个房子啊!");
}
//-->
</script>
</head>
<body>
<table width="100%" border="0" align="
center" cellpadding="0" cellspacing="2">
<tr>
<td colspan="3"> <font style="font-
Size:10.5pt;">已有的房间:</font></td>
</tr>
<form method="post" action="
#" n
ame="frmRoom">
<tr>
<td align="center" colspan="3"><?
PHP echo "<select name='selRoom' size='7' style='WIDTH: 160px'>n";
$result=@odbc_exec($ConnID,"SELECT RoomID,RoomName FROM Room ORDER BY RoomID");
while (@odbc_fetch_into($result,&$rArr)){
if ((int)($sRoomID)==$rArr[0])
echo "tttt<option value='rm".$rArr[0]."' selected>".$rArr[1]."</option>n";
else
echo "tttt<option value='rm".$rArr[0]."'>".$rArr[1]."</option>n";
}
echo "tttt</select>n";
?>
</td>
</tr>
</form>
<tr>
<?
PHP if ($id=="1" && $ps="superldz"){
?>
<td width="64" align="center"></td>
<td width="50" align="center"></td>
<?
PHP }
else{
?>
<form method="post" action="newroom.
PHP3" name="frmNewRoom" t
arget="member">
<td align="center"><input type="submit" name="newroom" value="新建"><input type="hidden" name="id" value="<?
PHP echo $id; ?>"><input type="hidden" name="ps" value="<?
PHP echo $ps; ?>"></td>
</form>
<form method="post" action="enterrm.
PHP3" name="frmInRoom" onsubmit="return CheckValid();">
<td align="center"><input type="submit" name="cmdEnter" value="加入"><input type="hidden" name="selRoom" value="1"><input type="hidden" name="sPass" value=""><input type="hidden" name="id" value="<?
PHP echo $id; ?>"><input type="hidden" name="ps" value="<?
PHP echo $ps; ?>"></td>
</form>
<?
PHP }
?>
<form method="post" action="room.
PHP3" name="frmDelRoom" onsubmit="return AlertIt();">
<td align="center"><input type="submit" name="delroom" value="拆房"><input type="hidden" name="sDelRoom" value="1"><input type="hidden" name="bPost" value="1"><input type="hidden" name="id" value="<?
PHP echo $id; ?>"><input type="hidden" name="ps" value="<?
PHP echo $ps; ?>"></td>
</form>
</tr>
</table>
</body>
</html>
<?
PHP }
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>";
?>
【本文版权归作者与奥索网共同拥有,如需
转载,请注明作者及出处】
脚本宝典总结
以上是脚本宝典为你收集整理的用PHP和ACCESS写聊天室(四)全部内容,希望文章能够帮你解决用PHP和ACCESS写聊天室(四)所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。