ASP常用功能模块的介绍

2019-04-26 08:22:01来源:爱站网 阅读 ()

新老客户大回馈,云服务器低至5折

? ? ? 每次写系统的时候都需要登录程序,这样就显得异常麻烦,其实我们吧几个常用的功能模块做成登录验证函数即可,那么ASP常用的几个功能模块有哪些呢?现在我们就去看看ASP常用功能模块的介绍。
[code]
<%
Function?chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl)dim?cn_name,cn_pwdcn_name=trim(request.form(""&requestname&""))cn_pwd=trim(request.form(""&requestpwd&""))if?cn_name=""?or?cn_pwd=""?thenresponse.Write("<script?language=javascript>alert(""请将帐号密码填写完整,谢谢合作。"");history.go(-1)</script>")end?ifSet?rs?=?Server.CreateObject?("ADODB.Recordset")sql?=?"Select?*?from?"&tablename&"?where?"&namefield&"=''"&cn_name&"''"rs.open?sql,conn,1,1if?rs.eof?thenresponse.Write("<script?language=javascript>alert(""没有该会员ID,请确认有没有被申请。"");history.go(-1)</script>")elseif?rs(""&pwdfield&"")=cn_pwd?then?session("cn_name")=rs(""&namefield&"")response.Redirect(reurl)elseresponse.Write("<script?language=javascript>alert(""提醒,您的帐号和密码是不吻合。注意数字和大小写。"");history.go(-1)</script>")end?ifend?ifrs.close?Set?rs?=?NothingEnd?Function%>
[code]
? ? ? 参数说明:
chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl)

requestname?为接受HTML页中输入名称的INPUT控件名
requestpwd?为接受HTML页中输入密码的INPUT控件名
tablename?为数据库中保存注册信息的表名
namefield?为该信息表中存放用户名称的字段名
pwdfield?为该信息表中存放用户密码的字段名
reurl?为登录正确后跳转的页

? ? ? 引用示例如下:
<%call?chk_regist("b_name","b_pwd","cn_admin","cn_name","cn_pwd","admin.asp")%>

? ? ? 2,经常有可能对某个事物进行当前状态的判断,一般即做一字段(数值类型,默认值为0)
? ? ? 通过对该字段值的修改达到状态切换的效果。那么,我又做了个函数,让自己轻松轻松。
<%Function?pvouch(tablename,fildname,autoidname,indexid)dim?fildvalueSet?rs?=?Server.CreateObject?("ADODB.Recordset")sql?=?"Select?*?from?"&tablename&"?where?"&autoidname&"="&indexidrs.Open?sql,conn,2,3fildvalue=rs(""&fildname&"")if?fildvalue=0?thenfildvalue=1elsefildvalue=0end?ifrs(""&fildname&"")=fildvaluers.updaters.close?Set?rs?=?NothingEnd?Function%>

? ? ? 参数说明:
pvouch(tablename,fildname,autoidname,indexid)

tablename?该事物所在数据库中的表名
fildname?该事物用以表明状态的字段名(字段类型是数值型)
autoidname?在该表中的自动编号名
indexid?用以修改状态的对应自动编号的值

? ? ? 引用示例如下:
<%dowhat=request.QueryString("dowhat")p_id=cint(request.QueryString("p_id"))if?dowhat="tj"?and?p_id<>""?thencall?pvouch("cn_products","p_vouch","p_id",p_id)end?if%><%if?rs("p_vouch")=0?then%>>推荐<%else%>>取消推荐<%end?if%>

? ? ? 3,为很多中小企业写站点,一般产品展示是个大项目,那么做成的页面也就不同。
? ? ? 要不就是横排来几个,要不就是竖排来几个,甚至全站要翻来覆去的搞个好几次,麻烦也很累。
? ? ? 索性写个函数能缓解一下,于是就成了下面
<%function?showpros(tablename,topnum,fildname,loopnum,typenum)Set?rs?=?Server.CreateObject?("ADODB.Recordset")sql?=?"Select?top?"&topnum&"?*?from?"&tablenamers.Open?sql,conn,1,1if?rs.eof?and?rs.bof?thenresponse.Write("暂时无该记录")elseresponse.Write("")for?i=1?to?rs.recordcountif?(i?mod?loopnum=1)?thenresponse.write"?"end?ifselect?case?typenumcase?"1"response.Write("?")response.Write(rs(""&fildname&""))response.Write("?")response.Write("方式1之"&i&"记录")''此处的“方式1”可以替换显示为其余字段的值response.Write("?")''如果字段比较多,继续添加新个表格行来显示response.Write("??")case?"2"response.Write("?")response.Write(rs(""&fildname&""))response.Write("?")response.Write("?")response.Write("方式2之"&i&"记录")response.Write("?")response.Write("??")end?selectif?(i?mod?loopnum=0)?thenresponse.write"?"end?ifrs.movenextnextresponse.Write("?")end?ifrs.close?Set?rs?=?Nothingend?function%>

参数说明:showpros(tablename,topnum,fildname,loopnum,typenum)
whichpro为选择何类型的产品种类
topnum表示提取多少条记录
fildname表示调试显示的字段,具体应用的时候可以省去该参数,在函数内部直接使用
loopnum表示显示的循环每行的记录条数
typenum表示循环显示的方法:目前分了两类,横向并列、纵向并列显示同一数据记录行的不同记录

引用示例如下:
<%if?request.form("submit")<>""?thentopnum=request.form("topnum")loopnum=request.form("loopnum")typenum=request.form("typenum")elsetopnum=8loopnum=2typenum=1end?if%><%call?showpros("cn_products",topnum,"p_name",loopnum,typenum)%>

? ? ? 以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助~如果有疑问大家可以留言交流,谢谢大家对爱站技术频道的支持!


原文链接:https://js.aizhan.com/develop/asp/5818.html
如有疑问请与原作者联系

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:分析HTML病毒

下一篇:自动采集程序的实例代码