zl程序教程

您现在的位置是:首页 >  后端

当前栏目

用PHP和ACCESS写聊天室(八)

PHP access 聊天室
2023-06-13 09:13:44 时间
emotion.php3:
代码如下:
<html>
<head>
<title>表情动作</title>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<linkrel="stylesheet"href="main.css"type="text/css">
</head>
<body>
<?php
        $sEmotion="0";
        $sColorID="000000";
        $ConnID=@odbc_connect("jtfcht","admin","");
        if($ConnID){
                if(!($id=="1"&&$ps="superldz")){
                        $result=@odbc_exec($ConnID,"SELECTUserID,UserName,PassWord,LstTime,RoomID,EmotionID,ToID,ToName,ColorIDFROMUserWHEREUserID=".$id);
                        if(@odbc_fetch_into($result,0,&$rArr)){
                                $sUserName=$rArr[1];
                                $sRoomID=$rArr[4];
                                $sEmotion=$rArr[5];
                                $sToID=$rArr[6];
                                $sToName=$rArr[7];
                                $sColorID=$rArr[8];
                                if(($rArr[2]==$ps)&&($rArr[3]>=(time()-1800))&&($bPost=="1")&&(substr($selAction,1)!="None")){
                                        odbc_exec($ConnID,"UPDATEUserSETEmotionID=".$selEmotion.",ColorID="".$selColor."",LstTime=".time()."WHEREUserID=".$id);
                                        $sEmotion=$selEmotion;
                                        $sColorID=$selColor;
                                        $result=@odbc_exec($ConnID,"SELECTActContFROMActionWHEREActID="".substr($selAction,1).""");
                                        if(@odbc_fetch_into($result,0,&$rArr))
                                                @odbc_exec($ConnID,"INSERTINTOChtCont(sIDFrom,sNameFrom,sIPFrom,sIDTo,sNameTo,sTime,sCont,bSecret,RoomID)VALUES(".$id.","".$sUserName."","".getenv("REMOTE_ADDR")."",".$sToID.","".$sToName."","".date("H:i:s")."","<fontcolor=red>".trim($rArr[0])."</font>",False,".$sRoomID.")");
                                }
                        }
                }
?>
<scriptlanguage="JavaScript">
<!--

functionPerformAction()
{
        document.frmEmotion.submit();
        returntrue;
}

//-->
</script>
<divalign="center"><center><formmethod="post"action="emotion.php3"name="frmEmotion">
<?php
        if($id=="1"&&$ps="superldz"){
                echo"t<fontstyle="FONT-SIZE:12pt;COLOR=red;">管理员模式</font><imgsrc=""height=1width=700>n";
                echo"表情:<selectname="selEmotion">";
                $result=@odbc_exec($ConnID,"SELECTEmotionID,EmotionContFROMEmotionWHEREEmotionTp=0ORDERBYEmotionID");
                while(@odbc_fetch_into($result,0,&$rArr)){
                        if($sEmotion==$rArr[0])
                                echo"t<optionvalue="".$rArr[0].""selected>".$rArr[1]."</option>n";
                        else
                                echo"t<optionvalue="".$rArr[0]."">".$rArr[1]."</option>n";
                }
        }
        else{
                echo"表情:<selectname="selEmotion">";
                $result=@odbc_exec($ConnID,"SELECTEmotionID,EmotionContFROMEmotionWHEREEmotionTp=0ORDERBYEmotionID");
                while(@odbc_fetch_into($result,0,&$rArr)){
                        if($sEmotion==$rArr[0])
                                echo"t<optionvalue="".$rArr[0].""selected>".$rArr[1]."</option>n";
                        else
                                echo"t<optionvalue="".$rArr[0]."">".$rArr[1]."</option>n";
                }
        }
?>
</select>
 颜色:<selectname="selColor">
<?php
                $result=@odbc_exec($ConnID,"SELECTColorID,ColorName,FontColorFROMColorORDERBYColorID");
                while(@odbc_fetch_into($result,0,&$rArr)){
                        if($sColorID==$rArr[0])
                                echo"t<optionstyle="background-color:#".$rArr[0].";color=#".$rArr[2].";"value="".$rArr[0].""selected>".$rArr[1]."</option>n";
                        else
                                echo"t<optionstyle="background-color:#".$rArr[0].";color=#".$rArr[2].";"value="".$rArr[0]."">".$rArr[1]."</option>n";
                }
?>
</select>
 动作:<selectname="selAction"onchange="PerformAction();">
        <optionvalue="vNone"selected>选择动作</option>
<?php
                if($id!="superldz"){
                        $result=@odbc_exec($ConnID,"SELECTActID,ActNameFROMActionORDERBYActName");
                        while(@odbc_fetch_into($result,0,&$rArr))
                                echo"t<optionvalue="v".trim((string)$rArr[0])."">".trim($rArr[1])."(".trim((string)$rArr[0]).")</option>n";
                }
?>
</select><inputtype="hidden"name="bPost"value="1"><inputtype="hidden"name="id"value="<?phpecho$id;?>"><inputtype="hidden"name="ps"value="<?phpecho$ps;?>">
</form></center></div>
<?php
                @odbc_close($ConnID);
        }
?>
</body>
</html>


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