VB 版 (精华区)
发信人: folmorse (◆金瓶楼主◆), 信区: VB
标 题: [ASP版]一个聊天室的简单例子
发信站: 大红花的国度 (Sun Jun 11 15:08:21 2000), 转信
转载] [范文][ASP版]一个聊天室的简单例子
发信站: 华南网木棉站 (Mon Dec 27 21:58:07 1999), 转信
【 以下文字转载自 New_board 讨论区 】
【 原文由 Mcu 所发表 】
<!--#include file="Util.asp" -->
<%
Name=Request("Name")
if Name="" then
Response.Redirect "chatroom.htm"
else
Session("Name")=Name
If Application(Name) = "In" Then
%><a href="chatroom.htm">此姓名(别名)已经被占用
</a><%
Else
Application(Name) = "In"
Session.TimeOut = 1
Response.Redirect "frame.htm"
End If
end if
%>
<!--#include file="Util.asp" -->
<%
If Request("Send") = "Send" then
mypath="Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath
("\Chatroom") & "\chatroom.mdb;"
mysql ="SELECT * FROM chatroom"
Set rec = Server.CreateObject("ADODB.recordset")
rec.CursorType =3
rec.CursorLocation =3
rec.LockType =2
rec.Open mysql, mypath
do while rec.RecordCount >15
rec.Movefirst
rec.Delete
loop
rec.AddNew
rec("姓名")=Session("Name")
rec("时间")=time()
rec("内容")=request("words")
rec.Update
rec.Close
words=""
End If
%>
<html>
<head>
<title>Happy聊天室</title>
</head>
<body BACKGROUND="b01.jpg">
<form action="talk.asp" method="POST">
<input type="hidden" name="Send" value="Send"><table>
<tr>
<td valign="top">聊天内容:<p><input type="Submit" value=" 提 交 "></t
d>
<td><textarea name="words" rows="3" cols="60" Wrap><%=words%></textare
a></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</form>
</body>
</html>
<%
Sub AddToNameList( Name, NameList )
If Len(NameList) = 0 Then
NameList = Name
ElseIf InStr( NameList, Name ) <= 0 Then
NameList = NameList & "," & Name
End If
End Sub
Function SqlStr( data )
SqlStr = "'" & Replace( data, "'", "''" ) & "'"
End Function
%>
<!--#include file="Util.asp" -->
<%
Dim DbPath,strProvider,conn
DbPath = SERVER.MapPath("ChatRoom.mdb")
strProvider="Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & DbPath
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open strProvider
Name=Session("Name")
Set rs = conn.Execute( "最近十笔谈话" )
URL=Request.ServerVariables("PATH_INFO")
freq=5
%>
<html>
<head>
<meta http-equiv="refresh" content="<%=Freq%>">
<meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title>My 聊天室</title>
</head>
<body background="b01.jpg">
<table border="0">
<%
While Not rs.EOF
%>
<tr>
<td valign="top"><font color="#0000ff">
<%=FormatDateTime(rs("时间"), vbShortTime)%></font></td>
<td valign="top"><font color="#ff0000">[
<%=rs("姓名")%>
]</font></td>
<td><font color="#0000ff">说:</font></td>
<td>
<%=Replace("" & rs("内容"), vbCrLf, "<BR>")%></td>
</tr>
<% wend %>
</table>
</body>
</html>
--
^-^
我始终相信自己的明天更美好,所以我一直在很努力的追求着那个梦想。
相信朋友,相信自己,相信机会面前人人平等。
付出终有回报!
※ 修改:.folmorse 于 Jun 11 15:07:36 修改本文.[FROM: hpwei.hit.edu.cn]
※ 来源:.华南网木棉站 bbs.gznet.edu.cn.[FROM: 202.38.250.115]
--
※ 转载:.华南网木棉站 bbs.gznet.edu.cn.[FROM: 202.38.248.167]
--
※ 转寄:.华南网木棉站 bbs.gznet.edu.cn.[FROM: hpwei.hit.edu.cn]
--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: folmorse.bbs@melon.g]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.280毫秒