电信主站 网通分站
购买流程 付款方式 常见问题 在线提问 续租服务 购物车
用户名: 密 码: 忘记密码?
首 页
域名注册
虚拟主机
双线主机
服务器租用
VPS主机
企业邮局
代理专区
客服中心
虚拟主机行业资讯 虚拟主机评测对比 互联网最新动态 技术学院 站长资讯 在线教程 网站运营
搜索优化 服务器 网络编程 图形图象 站长之家 网页制作 操作系统
冲浪宝典 软件教学 视频通信 办公软件 邮件系统 网络安全 认证考试
您当前位置:西部数码->资讯中心-> 网络编程 -> ASP教程
asp技术在论坛中的运用(八)(吐血推荐!!!!)_asp技巧
作者:网友供稿 点击:0
  西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!虚拟主机可在线rar解压,自动数据恢复设置虚拟目录等.虚拟主机免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金!
文章页数:[1] 
    使用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=gb2312">

  < /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=gb2312">

  < /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=gb2312">

  < /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没多大的关系,这儿就不多讲了。

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
相关主题
文章页数:[1] 
Google
热门文章
·将html表单数据存储为xml格式 - 1_asp实例
·一个功能完善的专栏管理的程序->这是asp.net的第二个应用(五)_asp实例
·通过事例学习.net的webforms技术(一)_asp实例
·通过事例学习.net的webforms技术(二)_asp实例
·如何用javascript识别netscape 6 浏览器_asp技巧
·使用javascript实现邮箱快速登录的方法!!_asp技巧
·如何从数据库得到一个列表表单_asp技巧
·使用cookie来跟踪用户_asp技巧
·一个免费的简单聊天室源代码_asp实例
·stripnonnumeric函数源程序_asp实例

最新文章
·ASP基础教程:其它的ASP常用组件
·ASP基础教程:学习ASP中子程序的应用
·ASP基础教程之ASP程序对Cookie的处理
·ASP基础教程之ASP AdRotator组件的使用
·ADO初学者教程:ADO 通过GetString()加速脚本
·ASP技巧实例:几行代码解决防止表单重复提交
·ASP常见数学函数 Abs Atn Cos 等详细详解[ 来源:网页教学网 | 作者: | 时间:2007-09-12 10:57:29 | 收藏本文 ] 【大 中 小】【名称】
·ASP基础教程之ASP AdRotator 组件的使用
·ASP读sql数据时出现乱码问题的解决方法
·PHP+MYSQL实例:网站在线人数的程序代码


 
 


版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!

特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
  打印  刷新  关闭
返回首页 |关于我们 | 联系我们 | 付款方式 | 创业联盟 | 虚拟主机 | 资讯中心 | 友情链接 | 网站地图

版权所有 西部数码(www.west263.com)
CopyRight (c) 2002~2006 west263.com all right reserved.
公司地址:四川成都市万和路90号天象大厦4楼 邮编:610031
电话总机:028-86262244 86263048 86263408 86263960 86264018 86267838
售前咨询:总机转201 202 203 204 206 208
售后服务:总机转211 212 213 214
财务咨询:总机转224 223 传真:028-86264041 财务QQ:点击发送消息给对方635483282
售前咨询QQ:点击发送消息给对方2182518 点击发送消息给对方241975952 点击发送消息给对方275026793 点击发送消息给对方408235859
售后服务QQ:点击发送消息给对方17708515 点击发送消息给对方307742704 点击发送消息给对方287976517 点击发送消息给对方363783715
《中华人民共和国增值电信业务经营许可证》编号:川B2-20030065号