asp论坛制作教程 BBS ASP源码.docx
- 文档编号:29792069
- 上传时间:2023-07-27
- 格式:DOCX
- 页数:23
- 大小:24.73KB
asp论坛制作教程 BBS ASP源码.docx
《asp论坛制作教程 BBS ASP源码.docx》由会员分享,可在线阅读,更多相关《asp论坛制作教程 BBS ASP源码.docx(23页珍藏版)》请在冰豆网上搜索。
asp论坛制作教程BBSASP源码
一、建立文件
1、数据库,用来储存发表的帖子!
-------命名为:
bbs.mdb
2、有数据库就必须连接数据库,该文件用来连接数据库:
----命名为:
conn.asp
3、发表帖子的文件----命名为:
say.asp
4、保存发表帖子内容的文件-----命名为:
save.asp
5、显示帖子标题的文件------命名为:
index.asp
6、显示帖子内容的文件,即点击标题后所进入的页面-----命名为:
show.asp
7、删除帖子内容的文件-----命名为:
del.asp
8、修改帖子内容的文件-----命名为:
modify.asp
9、修改后保存帖子内容的文件-----命名为:
modifysave.asp
10、保存回复内容------wback.asp
11、CSS样式表文件------main.css
12、页面上部----header.htm
13、页面下部------footer.htm
二、各文件的主要内容
1、bbs.mdb
打开这个数据库,就是Access建立三个表
bbs:
id(自动给帖子编号),他的数据类型设为“自动编号”
name(用来储存发表的作者),数据类型为“文本”
title(用来储存帖子的主题),数据类型为“文本”
body(用来储存帖子的内容),数据类型为“备注”
wtime(撰写时间)时间
countwb(回复计数)整数
bbbs:
回复数据保存
hostid(楼主ID)文本
btime(回复时间)时间
bname(回复人名字)文本
bid(回复文章ID)数字
bcontent(回复内容)备注
btitle(回复主题)文本
author:
name(名字)文本
code(密码)文本
sex(性别)文本
birth(出生)文本
com(联系方式)文本
2、conn.asp
源代码为:
<%Server.scriptTimeout="10"
connstr="DBQ="+server.mappath("bbs.mdb")+";DefaultDir=;DRIVER={MicrosoftAccessDriver(*.mdb)};"
setconn=Server.CreateObject("ADODB.connection")
conn.openconnstr%>
建立连接,"bbs.mdb"是刚建立的数据库文件。
3、say.asp
--#includefile="header.htm"-->
<%subsaysth()
name=request.QueryString("name")%>
style="border-collapse: collapse;"bordercolor="#000000" width=600height="20"align=centerID="Table1"> 发表文章: 大名: 密码: 12px"> 点此 标题: 内容:
<%endsub
'用过程和函数调用的方式,能容易理解。
'这里只是一个表单提交(到save.asp)
%>
--#includefile="footer.htm"-->
4、save.asp
--#includefile="conn.asp"-->
--#includefile="header.htm"-->
<%subsave()
name=Replace(Request.Form("name"),"'","''")
title=Replace(Request.Form("title"),"'","''")
body=Replace(Request.Form("body"),"'","''")
code=Replace(Request.Form("code"),"'","''")
setsavebbs=conn.execute("select*fromauthorwherename='"&name&"'"&"andcode='"&code&"'")
ifname=""ortitle=""orbody=""orcode=""orsavebbs.eofthen%>
请
点此
<%else
sql="insertintobbs(name,title,body,wtime,countwb)values('"&name&"','"&title&"','"&body&"','"&now()&"',0)"
setsavebbs=conn.execute(sql)
setsavebbs=nothing
setsavebbs=conn.execute("select*frombbswherename='"&name&"'orderbywtimedesc")
'打开数据表,插入数据。
%>
发表成功!
id=<%=savebbs("id")%>">查看帖子| <%endif setsavebbs=nothing endsub %>
--#includefile="footer.htm"-->
5、index.asp
源代码:
<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%>
--#includefile="conn.asp"-->
--#includefile="header.htm"-->
<%submaintalk()%>
<%
setshowbbs=server.CreateObject("ADODB.recordset")
showbbsStr="select*frombbsorderbywtimedesc"
showbbs.openshowbbsStr,conn,3,2
ifshowbbs.EOFandshowbbs.BOFthen%>
<%else
showbbs.PageSize=10'分页
PageN=10'显示10个页数.
PageCount=showbbs.PageCount
Page=int(request("Page"))
CurrentPageN=int(request("CurrentPageN"))
ifPage<=0orrequest("Page")=""orrequest("Page")="0"thenPage=1
ifCurrentPageN<=0orrequest("CurrentPageN")=""thenCurrentPageN=1
showbbs.AbsolutePage=Page
%>
<%fori=1toshowbbs.PageSize%>
id=<%=showbbs("id")%>"><%=showbbs("title")%>
作者:
auname=<%=showbbs("name")%>"><%=showbbs("name")%> <%ifshowbbs("countwb")=0then%> 回复<<%=showbbs("countwb")%>> --回复条数--> <%else%> id=<%=showbbs("id")%>"> 回复< --回复条数--> <%endif%> <%wt=showbbs("wtime")'如果为撰写当天的时间,红色显示。 ifyear(now())=year(wt)andmonth(now())=month(wt)andday(now())=day(wt)then%> 撰写/修改时间: <%else%> 撰写/修改时间: <%=wt%> <%endif%> id=<%=showbbs("id")%>">修改 id=<%=showbbs("id")%>">删除
dashed#999999"> <%showbbs.movenext ifshowbbs.EOFthenexitfor Next%>
<%'以下为页码显示。
ifPage<>1then%>
Page=1&CurrentPageN=1">(首页) <%else%> (当前为首页) <%endif%> <%ifPageCount>PageNandCurrentPageN>=2then%> Page=<%=(CurrentPageN-2)*PageN+1%>&CurrentPageN=<%=CurrentPageN-1%>">(上<%=PageN%>页) <%endif%> <%fori=(CurrentPageN-1)*PageN+1to(CurrentPageN-1)*PageN+PageN%> <%ifi=Pagethen%> <%elseifi page=<%=i%>&CurrentPageN=<%=CurrentPageN%>"> <%=i%> <%endif%> <%Next%> <%ifPageCount>PageNandCurrentPageN Page=<%=CurrentPageN*PageN+1%>&CurrentPageN=<%=CurrentPageN+1%>">(下<%=PageN%>页) <%endif%> <%ifPageCount>PageNandPage<>PageCountthen%> Page=<%=PageCount%>&CurrentPageN=<%=int(PageCount/PageN)+1%>">(最后一页) <%endif%> <%ifPageCount=Pagethen%>(当前为最后页)<%endif%> (共<%=PageCount%>页) <%showbbs.Close setshowbbs=nothing endif endsub%> ---------------------------------------------------> <%subsaysth() '下方的快捷发表表单 name=request.QueryString("name")%> style="border-collapse: collapse;" width=600align=center> 发表文章: 大名: 密码: 12px"> 点此 标题: 内容: <%endsub%> ------------------------------------------------------------->
--#includefile="footer.htm"-->
6、show.asp
源代码:
--#includefile="conn.asp"-->
--#includefile="header.htm"-->
<%id=request.querystring("id")
setshow=conn.execute("select*frombbswhereid="&id&"")'全局%>
<%submaintalk
'主文章%>
<%=show("title")%>
作者:
auname=<%=show("name")%>"><%=show("name")%> 撰写/修改时间: <%=show("wtime")%> id=<%=show("id")%>">修改 id=<%=show("id")%>">删除
<%=show("body")%>
<%endsub%>
<%subwbtalk()
'回复文章%>
<%sql="select*frombbbswherehostid='"&id&"'orderbybtimeasc"
setshowwback=conn.execute(sql)
floori=0
dowhilenotshowwback.eof'没有像主页那样分页,原理相同。
floori=floori+1%>
<%=floori%>楼:
<%=showwback("btitle")%>