您的位置:首页精文荟萃软件资讯 → ASP技术在论坛中的运用八(吐血推荐!!!!)

ASP技术在论坛中的运用八(吐血推荐!!!!)

时间:2004/10/7 19:04:00来源:本站整理作者:蓝点我要评论(0)


            
             
              
             
            

               
               

            



            使用Session来保持对斑竹的身份验证,这必须要求客户端浏览器的cookie被打开了。因为Session是通过cookie来实现的。在这儿,把看板ID赋给Session变量beenthere,表明斑竹已经通过了身份验证。在后面的每个版务处理的页面中,都要检查beenthere是否和相应的看版ID相符。

  url="boardmanager.asp?boardid=" & boardid

  response.redirect url

  初学ASP的时候总是为response.redirect这个方法感到困惑,屡用不爽,现在我来告诉你一些技巧。使用它之前,必须通过response.buffer=true来让ASP页面使用缓冲区。这时,在ASP被解释成HTML代码之前,它是放在缓冲区中的,而不直接被发送的客户端浏览器。还有一个必须要知道的是:在使用response.redirect之前,是不能有任何实际的HTML代码被发送到客户端浏览器的,否则就会出错。当然也有变通的方法,如果在response.redirect之前已经有HTML代码被解释出来,可以用response.clear方法来清除缓冲区,然后就可以使用它来进行重定向了。

  end if

  %>

   

   下面的页面,就是在上面身份验证通过后重定向的目标:boardmanager.asp。它将列出了所有别有被处理的文章。

  < %

  boardid=request("boardid")

  if session("beenthere")< >boardid then response.redirect "forums.asp"

  这就是检验斑竹身份的地方,因为前面已经通过cookie在斑竹的浏览器中作了标记,现在我们就能够通过seesion来辨认斑竹的身份了。如果标志不符,就会通过response.redirect返回到最开始的登陆页面。如果斑竹浏览器的cookie没有打开,那么seesion(“beenthere“)的值会为空,同样也无法进入这个页面。

  Set conn = Server.CreateObject("ADODB.Connection")

  conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("bbssystem.mdb")

  Set cmd = Server.CreateObject("ADODB.Command")

  Set cmd.ActiveConnection = conn

  sql="select 名称 from 看板列表 where id=" & boardid

  set rs=conn.execute(sql)

  boardname=rs("名称")

   cmd.commandtext="未发表文章列表"

   ReDim param(0) ' 声明

  param(0) = CLng(boardid) ' Cint 不可忽略

  Set rs = cmd.Execute( ,param )

  set cmd=nothing

  %>

  < html>

  < head>

  < title>版务处理< /title>

  < meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  < /head>

  < body bgcolor="#FFFFFF">

  < h1 align="center">< %=boardname%>板板务管理< /h1>

  < hr>

  < %

  if rs.eof or rs.bof then response.write "< H2>现在没有文章要处理< /h2>"

  response.end

  %>

   如果没有新文章被网友发布,这给出相应的提示,并用response.end来结束此页的显示。

  < table width="90%" border="0" cellspacing="0" cellpadding="0" align="center" >

   < tr bgcolor="#FFFFCC">

   < td width="40%" height="20">主题< /td>

   < td width="40%" height="20">文章标题< /td>

   < td width="8%" height="20">作者< /td>

   < td width="12%" height="20">日期< /td>

   < /tr>

   < %

  do

  topicid=rs("主题id")

   articleid=rs("文章id")

   data=rs("日期")

  datastr=cstr(year(data)) & "-" & cstr(month(data)) &"-" & cstr(day(data))

  author=rs("作者")

   articlename=rs("标题")

   topicname=rs("主题")

  

  response.write "< tr>< td>< a href=qtopic.asp?topicid="& topicid & ">" & topicname & "< /A>< /td>"

  response.write "< td>< a href=managearticle.asp?articleid="& articleid & "&boardid=" & boardid &">" & articlename & "< /A>< /td>"

  response.write "< td>< a href=qauthor.asp?author="& author & ">" & author & "< /a>< /td>"

  response.write "< td>" & datastr & "< /td>< /tr>"

  rs.movenext

  loop until rs.eof

  %>

  < /table>

  < /html>

  < %

  set rs=nothing

  conn.close

  set conn=nothing

  %>

  < /body>

   当点击了相应文章的联结后,就进入此文章的处理页面managearticle.asp:

  < %

  articleid=request("articleid")

  boardid=request("boardid")

  if session("beenthere")< >boardid then response.redirect "forums.asp"

  Set conn = Server.CreateObject("ADODB.Connection")

  conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("bbssystem.mdb")

  Set cmd = Server.CreateObject("ADODB.Command")

  Set cmd.ActiveConnection = conn

  cmd.CommandText = "按id查询文章"

   ReDim param(0) ' 声明

  param(0) = CLng(articleid) ' Cint 不可忽略

  Set rs = cmd.Execute( ,param )

  author=rs("作者id")

   title=rs("标题")

   data=rs("日期")

   rate=rs("推荐度")

   boardid=rs("看板id")

   topicid=rs("主题id")

   boardname=rs("看板名")

   topicname=rs("主题名")

   content=rs("内容")

  content=replace(content,vbCrlf,"< /p>< p>")

  content="< p>" & content & "< /p>"

  set cmd=nothing

  %>

  < html>

  < head>

  < title>Untitled Document< /title>

  < meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  < /head>

  < body bgcolor="#E9E9E4">

  < table width="89%" border="0" cellspacing="0" cellpadding="0" align="center">

   < tr bgcolor="#CCCCCC">

   < td>作者:< font color="#FF3366">< a href="qauthor.asp?author=< %=author%>"> < %=author%> < /a>< /font> 发表日期:< font color="#FF3333">< %=data%>< /font>

   看板:< font color="#FF3333">< a href="qboard.asp?boardid=< %=boardid%>"> < %=boardname%>< /a>< /font> 板主推荐:< font color="#FF3333">#rate#< /font>< /td>

   < /tr>

   < tr bgcolor="#CCCCCC">

   < td>标题:< font color="#FF3333">< %=title%>

   主题:< a href="qtopic.asp?topicid=< %=topicid%>"> < %=topicname%> < /a> < /font>< /td>

   < /tr>

   < tr valign="top">

   < td>

   < hr>

   < font color="#FF3366">文章内容: < /font>< br>

   < br>

   < font color=blue>< %response.write content%>< /font>

   < br>

   < hr>

   < /td>

   < /tr>

   < tr valign="top">

   < form method="post" action="manageresult.asp">

   < td height="18">

   < table width="100%" border="1" cellspacing="1" cellpadding="1">

   < tr>

   < td width="29%">

   < div align="right">

   < input type="hidden" name="boardid" value="< %=boardid%>">

   < input type="hidden" name="topicid" value="< %=topicid%>">

   < input type="hidden" name="articleid" value="< %=articleid%>">

  文章处理:< /div>

   < /td>

   < td width="12%" bordercolor="#006666">删除:

   < input type="radio" name="manage" value=1>

   < /td>

   < td width="30%" bordercolor="#006666">发表:

   < input type="radio" name="manage" value=2>

  推荐等级

   < select name="select">

   < option value="1">1< /option>

   < option value="2">2< /option>

   < option value="3" selected>3< /option>

   < option value="4">4< /option>

   < option value="5">5< /option>

   < /select>

   < /td>

   < td width="20%" bordercolor="#006666">以后在处理:

   < input type="radio" name="manage" value=3>

   < /td>

   < td width="9%">

   < input type="submit" name="Submit" value="确定">

   < /td>

   < /tr>

   < /table>

   < /td>

   < /form>

   < /tr>

  < /table>

  < /body>

  < /html>

  < %

  set rs=nothing

  conn.close

  set conn=nothing

  %>

  这一页和文章显示模块中的article.asp基本上是一样的,仅仅是多加入了斑竹处理的表单,在这儿就不多讲了。

  下面,要根据斑竹的处理过程,修该数据库相应部分:

  < %response.buffer=true%>

  < html>

  < head>

  < title>文章处理< /title>

  < meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  < /head>

  < body bgcolor="#E9E9E4">

  < %

  articleid=request("articleid")

  boardid=request("boardid")

  topicid=request("topicid")

  manage=request("manage")

  ‘接受表单内容

  response.write manage ‘显示斑竹ID

  if session("beenthere")< >boardid then response.redirect "forums.asp"

  Set conn = Server.CreateObject("ADODB.Connection")

  conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("bbssystem.mdb")

  根据上页中斑竹的操作,进行相应的处理。

  if CLng(request("manage"))=1 then

  sql="delete from 内容表 where id=" & articleid

  conn.execute sql

  response.write "< h1>文章已经被删除< /h1>"

  response.write "< a href=>back< /a>"

  elseif CLng(request("manage"))=2 then

  sql="update 内容表 set 发表=true where id=" & articleid

  conn.execute sql

  sql="update 主题表 set 文章数=文章数+1 where id=" & topicid

  conn.execute sql

  response.write "< h1>文章已经发表< /h1>"

  response.write "< a href=>back< /a>"

  else

  response.clear

  response.redirect "boardmanager.asp?boardid=" & boardid

  end if

  %>

  < /body>

  < /html>

  < %

  conn.close

  set conn=nothing

  %>

   到这儿,所有的部分就算是基本完成了。当然,这只是一个试验品,摆不上台面的。如果想要能够拿得出来的话,还要在版面设计,客户端数据验证等方面多下一些功夫。不过那都是HTML的内容了,和ASP没多大的关系,这儿就不多讲了。

相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3

最新文章 微信3.6.0测试版更新了微信支付漏洞会造成哪 360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗

人气排行 xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本