新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > Web开发 > Asp教程 > 正文:一各简单的bbs(四)

一各简单的bbs(四)

新客网 XKER.COM 2003-07-11 来源: 收藏本文
发言的服务器端页面bbs.asp:

<%
dim flag
flag=0
name=REQUEST.FORM("name")
code=REQUEST.FORM("code")
insubject=request.form("subject")
incontent=REQUEST.FORM("content")
subject="'"&request.form("subject")&"'"
content="'"&REQUEST.FORM("content")&"'"
curdate=Date
curtime=Time
set conn = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("author.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
set RS = Conn.Execute("SELECT * FROM author ")
do while not rs.eof
if rs("authorname")=name and rs("password")=code then
flag=1
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Application.Lock
TxtPath = Server.MapPath("bbs.txt")
Set InStream = fso.OpenTextFile (txtpath, ,true)
number = Cstr(InStream.Readline+1)
Set OutStream = fso.CreateTextFile (txtpath)
OutStream.WriteLine number
If Request.QueryString("ID")="" Then
manswernum=number
Else
manswernum=Request.QueryString("ID")
End If
If Request.QueryString("topnum")="" Then
mtopnum=number
Else
mtopnum=Request.QueryString("topnum")
End If
Set OutStream = Nothing
application.unlock
inname="'"&name&"'"
Set connbbs = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("bbs.mdb")
connbbs.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
Connbbs.Execute("INSERT INTO bbs(ID,authorname,subject,content,adddate,answernum,topnum,visitnum) Values("&number& ","&inname& ","&subject& "," &content& "," &curdate& " ,"&manswernum& "," &mtopnum& ",0)")

Connbbs.Close %>
<% =name %><p>
<% =insubject %><p><% =curdate & " " %><% =curtime & " 添加贴子 " %><p>
<% =incontent %><p><a href="disp.asp">返回论坛</a>
<%
exit do
response.flush
Else
rs.movenext
%>
<% End If
loop
RS.Close
Conn.Close %>
<%if flag=0 then%>
您的用户名或密码出错,请您<a href="bbs_add.htm">重输!</a>
<%end if%>
收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐