asp 學習聊天室

2021-04-01 22:10:17 字數 1035 閱讀 4891

了解了整個程式的核心部分,下面考慮如何儲存客戶資訊,這裡要用到乙個會話級的變數,即將客戶的nick儲存到session中,如:

session("nick")=request.form("nick")

最後我們要考慮的如何在asp檔案中處理多種事件:如客戶登陸介面, 客戶聊天介面 ,由於客戶第一次請求.asp檔案時,採用的是簡單的httpget方式,但是客戶在頁面的表單字段中新增資料並向自身提交表單後,.asp檔案會再次被請求,不過這次資料是經過 httppost方式進行傳遞的.檔案被請求的方式可以用良種方法來確定: 一是測試request.form集合是否包含成員,若沒有,則沒有,傳送給表單處理的資料; 二是使用request.servervaiables("request_method")變數,如果表單是通過httpget方式被請求,則這個變數會返回"get",如果表單被提交處理則返回"post".由於後一種方法對於確定檔案的請求方式更直接,所以我們使用如下**進行判斷:

ifrequest.servervariables("request_method")="get" then

由於我們設定了asp快取,所以程式判斷截面的請求方式為 get時,程式執行response.end來結束後面的所有操作,否則執行response.clear清空快取中已經有的內容,

**的實現:

<% @language=vbscript%>

<%response.buffer=true '設定輸出快取,用於顯示不同頁面

if request.servervariables("request_method")="get" then

'判斷客戶是以什麼方式請求頁面

''客戶登陸截面

<%'街道戶程式的處理

response.end

else

'清空快取中的內容

response.cleardimtalk

if response.form("nick")<>""then

''判斷客戶是否在聊天截面中

session("nick")=reqest.form("nick")

end if

mysql 聊天室 聊天室php mysql 六

聊天室php mysql 六 相應的 資料庫 phpmyadmin mysql dump 主機 localhost 3306 資料庫 study28 資料表的結構 chat user create table chat user userid varchar 20 not null,passwd v...

聊天室程式

伺服器 include include include include include include include include define servport 8081 伺服器端口號 define bufsize 200 最大傳輸量 int main int args,char argv s...

簡單聊天室

include include include include include include include include include include pthread t thread 2 void send msg void ip msg if connect sockfd,struct ...