一个简单的聊天室示例,代码如下:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME=“GENERATOR” Content=“Microsoft Visual Studio 6.0”>
</HEAD>
<BODY BGCOLOR=#COD9D9>
<%
Response.Buffer=true
On error resume next
If Request.ServerVariables(“Request_Method”)=“GET” then
%>
<FORM METHOD=“POST” ACTION=“chat1.asp”><P>
<H3>请输入你的昵称</H3>
<INPUT TYPE=“TEXT” NAME=“nick” VALUE=““>
<P>
<INPUT TYPE=“SUBMIT” NAME=“B1” VALUE=“进入”>
<P>
<INPUT TYPE=“HIDDEN” NAME=“log” VALUE=“1”>
</FORM>
<%
Response.End
Else
Response.clear
Response.Write(“<BODY BGCOLOR=#COD9D9>“)
Dim talk
If Request.Form(“nick”)<>“,then
Session(“nick”)=Request.Form(“nick”)
End If
%>
<FORM METHOD=“POST” ACTION=“chat1.asp”>
<P>
<H3><%=Session(“nick”)%> 消息:</H3>
<INPUT TYPE=“TEXT” NAME=“talk” SIZE=“50”>
<P>
<INPUT TYPE=“SUBMIT” VALUE=“提交” NAME=“B1”>
<INPUT TYPE=“RESET” VALUE=“取消” NAME=“B2”>
</FORM>
<A HREF=“chat1.asp”> 返回 </A>
<P>
<%
If Request.Form(“log”)<>1 then
If TRIM(Request.Form(“talk”))=“,then
talk=Session(“nick”)&”沉默是金。”
Else
talk=TRIM(Request.Form(“talk”))
End If
Application.lock
Application(“show”)=“<table border='0' cellpadding='0' cellspacing='0' width='85%'>
<tr><td width='100%' bgcolor='#C0C0C0'></td></tr><tr><td width='100%'><font color=
'#0000FF'> 来自,&Request.ServerVariables(“remote_addr”)&” 的,&Session(“nick”)&
time&” 说:</font>,&talk&”</td></tr><tr><td width='100%'bgcolor='#C0C0C0'></td>
</tr></table><br>“&Application(“show”)
Application.Unlock
Response.Write Application(“show”)
End If
End If
%>
</BODY>
</HTML>
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME=“GENERATOR” Content=“Microsoft Visual Studio 6.0”>
</HEAD>
<BODY BGCOLOR=#COD9D9>
<%
Response.Buffer=true
On error resume next
If Request.ServerVariables(“Request_Method”)=“GET” then
%>
<FORM METHOD=“POST” ACTION=“chat1.asp”><P>
<H3>请输入你的昵称</H3>
<INPUT TYPE=“TEXT” NAME=“nick” VALUE=““>
<P>
<INPUT TYPE=“SUBMIT” NAME=“B1” VALUE=“进入”>
<P>
<INPUT TYPE=“HIDDEN” NAME=“log” VALUE=“1”>
</FORM>
<%
Response.End
Else
Response.clear
Response.Write(“<BODY BGCOLOR=#COD9D9>“)
Dim talk
If Request.Form(“nick”)<>“,then
Session(“nick”)=Request.Form(“nick”)
End If
%>
<FORM METHOD=“POST” ACTION=“chat1.asp”>
<P>
<H3><%=Session(“nick”)%> 消息:</H3>
<INPUT TYPE=“TEXT” NAME=“talk” SIZE=“50”>
<P>
<INPUT TYPE=“SUBMIT” VALUE=“提交” NAME=“B1”>
<INPUT TYPE=“RESET” VALUE=“取消” NAME=“B2”>
</FORM>
<A HREF=“chat1.asp”> 返回 </A>
<P>
<%
If Request.Form(“log”)<>1 then
If TRIM(Request.Form(“talk”))=“,then
talk=Session(“nick”)&”沉默是金。”
Else
talk=TRIM(Request.Form(“talk”))
End If
Application.lock
Application(“show”)=“<table border='0' cellpadding='0' cellspacing='0' width='85%'>
<tr><td width='100%' bgcolor='#C0C0C0'></td></tr><tr><td width='100%'><font color=
'#0000FF'> 来自,&Request.ServerVariables(“remote_addr”)&” 的,&Session(“nick”)&
time&” 说:</font>,&talk&”</td></tr><tr><td width='100%'bgcolor='#C0C0C0'></td>
</tr></table><br>“&Application(“show”)
Application.Unlock
Response.Write Application(“show”)
End If
End If
%>
</BODY>
</HTML>