网站建设之最简单的聊天室程序

文章类型:常见问题    发表2010-02-15   文章编辑:怒熊网络 · 一站式互联网+技术服务商!   阅读:326

想到聊天室,你一定会认为非常复杂非常麻烦的吧,呵呵,这仅仅只有一段简单的ASP代码,实现了聊天室的基本功能,不妨参考下:将以下代码保存为liaotian.asp

<%If Request.ServerVariables('Request_Method')='GET' then%>
<form method='post' action='liaotian.asp'>
<input type='text' name='nick' Value='您的昵称'><p>
<input type='submit' Value='come in'><p>
<input type='hidden' name='log' size='20' Value='1'>
</form>
<%Response.End
Else
Response.clear
dim talk
If Request.Form('nick')<>'' then
Session('nick')=Request.Form('nick')
End if
%>
<form method='post' action='liaotian.asp' name=form1>
<%=Session('nick')%>说话:
<input type='text' name='talk' size='50'><br>
<input type='submit' Value='提交'>
<input type='reset' Value='取消'></p>
</form>
<a href='liaotian.asp'>离开</a><br>
<%
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')='来自'&Request.ServerVariables('remote_addr')& '的' &Session('nick')&'在'&time& '的时候说:' &talk& '<br>' &Application('show')
Application.UnLock
Response.Write Application('show')
End if
%>
<%End if%>

提示:将V改成v