|
蓝森林 http://www.lslnet.com 2006年8月25日 8:28
[asp]关于聊天室的程序
我仿写了一个简单的聊天室,但是根本就没有运转起来,不知道错在哪里,所以贴出来请教请教,以前发了一个,但是不知道什么原因被锁了,猜想可能是发帖格式不对,麻烦斑竹大哥手下留情,不要再锁了,锁了也请给我一个理由,我都一头雾水
global.asa
<script language=vbscript runat=server>
sub application_onstart
application("chat_num")=0
application("chat_list")=0
application("chat_words")=0
end sub
</script>
|
[html]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>TT聊天室</title>
</head>
<body>
<h2 align=center>欢迎来到TT聊天室</h2><br>
<form action=../chat_checkin.asp method=post onsubmit=checkvalue() >
<table width=60% align=center bgcolor="#88ddff" cellspacing=0>
<tr><td align=center>网友聊天室
<tr><td>
<table width=100% bgcolor=white border=0>
<tr><td>
<tr><td width=30%><td align=right>
<td>聊天室中的人数:<% application("chat_num") %></td>
<tr><td><td align=right><td>聊天室中的列表:<select><% =application("chat_list") %></select>
<tr><td> </table><table width=100% bgcolor=white dorder=0>
<tr><td align=center> 您的昵称:<input name=uset_nickname><tr><td>
<tr><td align=center><input type=submit value=马上进入>
<tr><td>
</table></table>
</form>
<script language=VBScript>
sub checkvalue( )
'检查是否输入了昵称
if document.all.user_nickname.value="" Then
alert ("请输入您聊天用的昵称,并且不得与他人相同!")
window.event.returnvalue=false
end if
end sub
</script>
</body>
</html>[/html] |
[html]<% response.Buffer=true %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>TT聊天室</title>
</head>
<body>
<%
user_nickname=request.form("user_nickname") ' 先检查昵称是否为空
if user_nickname="" then
response.redirect"chat_login.asp"
end if '再检查昵称是否重复
if instr(application("chater_list"),user_nickname)<>0 then
response.write"<p align=center>"
response.write"对不起,该昵称已经有人使用,请选择新的昵称!"
response.write"</p>"
response.write"<p align=center><a href=chat_login.asp>单击返回</a></p>"
response.End
end if
' 是新用户的昵称,将之加入名称列表
session("chater_name")=user_nickname
str="<option value=" &user_nickname& ">"
str=str &user_nickname & "</option>"
application.lock
' 将用户加入到聊天室的列表中
application("chater_list")=str &application("chater_list")
' 聊天室中的用户数目加1
application("chater_num")=applicaiton("chater_num")+1
str="<p>"
str=str &"("&time&")"
str=str &User_nickname
str=str & "进入聊天室......"
str=str &"</P>"
'添加用户进入聊天室信息
application("chater_words")=str &application("chater_words")
application.UnLock
'进入聊天室主界面
response.redirect"chat_main.asp" %>
</body>
</html>[/html] |
[html]<html>
<head>
<title>TT聊天室</title>
</head>
<frameset border=0 rows="75%,*" frameborder="0">
<frame name="f1" src="chat_main.asp">
<frame name="f2" src="chat_input.asp">
</frameset>
</html>[/html] |
[html]<% response.expires=0 %>
<html>
<head>
<title>输入聊天话语</title>
</head>
<body bgcolor=#9999ff>
<% chater=session("chater_name") %>
<form action=chat_showex.asp method=post target="f1">
<table bordet=0 cellspacing=0 align=center>
<tr>
<td>聊友:<% =chater %>
<select name=expression>
<option selected value="说话">说话</option>
<option value="悄悄地">悄悄地</option>
<option value="微笑着">微笑着</option>
<option value="哈!哈!哈!地笑着">大笑三声</option>
<option value="快要哭着">快要哭地</option>
<option value="伤感地">伤感地</option>
</select>
对<select name=saytoname>
<option selected value="所有人">所有人</option>
<% =application("chater_list") %></select> 说 (共<% =application("chater_num") %> 人)</td></tr>
<tr><td>内容:<input name=mywords size=30>
<input type=submit value=发送></table></form>
<form action=chat_quit.asp method=post target=_top>
<p align=center>
<input type=submit value="离开">
<input tyoe=botton value="刷新" onClick=refresh()></p></form>
<script language=vbscript >
sub refresh()
document.url="chat_input.asp"
end sub
</script>
</body>
</html>[/html] |
[html]<% response.buffer=true %>
<html>
<head>
<title>处理聊天室信息</title>
</head>
<body>
<%
'获得聊天室信息
mywords=trim(request.form("mywords"))
saytoname=request.form("saytoname")
expression=request.form("expression")
if expression="说话" then
expression=""
end if
'处理聊天的信息
str="<p>"
str="("&time&")"
str=str&session("chater_name")
str=str&"<i>" &expression&"对"
str=str&"<font color=#20b2aa>" &saytoname&"</font>说 </i>:"
str=str&mywords
str=str&"</p>"
'更新聊天内容变量
application.Lock
application("chater_words")=str&application("chater_words")
application.UnLock
'转至内容显示页面
response.Redirect"chat_show.asp"
%>
</body>
</html>[/html] |
在线等待...... |
好几天没有人回答了,伤心。55555 |
|