国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP常用功能模塊的介紹

2024-05-04 11:05:14
字體:
供稿:網(wǎng)友

? ? ? 每次寫系統(tǒng)的時(shí)候都需要登錄程序,這樣就顯得異常麻煩,其實(shí)我們吧幾個(gè)常用的功能模塊做成登錄驗(yàn)證函數(shù)即可,那么ASP常用的幾個(gè)功能模塊有哪些呢?現(xiàn)在我們就去看看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(""沒有該會(huì)員ID,請確認(rèn)有沒有被申請。"");history.go(-1)</script>")elseif?rs(""&pwdfield&"")=cn_pwd?then?session("cn_name")=rs(""&namefield&"")response.Redirect(reurl)elseresponse.Write("<script?language=javascript>alert(""提醒,您的帳號和密碼是不吻合。注意數(shù)字和大小寫。"");history.go(-1)</script>")end?ifend?ifrs.close?Set?rs?=?NothingEnd?Function%>
[code]
? ? ? 參數(shù)說明:
chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl)

requestname?為接受HTML頁中輸入名稱的INPUT控件名
requestpwd?為接受HTML頁中輸入密碼的INPUT控件名
tablename?為數(shù)據(jù)庫中保存注冊信息的表名
namefield?為該信息表中存放用戶名稱的字段名
pwdfield?為該信息表中存放用戶密碼的字段名
reurl?為登錄正確后跳轉(zhuǎn)的頁

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

? ? ? 2,經(jīng)常有可能對某個(gè)事物進(jìn)行當(dāng)前狀態(tài)的判斷,一般即做一字段(數(shù)值類型,默認(rèn)值為0)
? ? ? 通過對該字段值的修改達(dá)到狀態(tài)切換的效果。那么,我又做了個(gè)函數(shù),讓自己輕松輕松。
<%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%>

? ? ? 參數(shù)說明:
pvouch(tablename,fildname,autoidname,indexid)

tablename?該事物所在數(shù)據(jù)庫中的表名
fildname?該事物用以表明狀態(tài)的字段名(字段類型是數(shù)值型)
autoidname?在該表中的自動(dòng)編號名
indexid?用以修改狀態(tài)的對應(yīng)自動(dòng)編號的值

? ? ? 引用示例如下:
<%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,為很多中小企業(yè)寫站點(diǎn),一般產(chǎn)品展示是個(gè)大項(xiàng)目,那么做成的頁面也就不同。
? ? ? 要不就是橫排來幾個(gè),要不就是豎排來幾個(gè),甚至全站要翻來覆去的搞個(gè)好幾次,麻煩也很累。
? ? ? 索性寫個(gè)函數(shù)能緩解一下,于是就成了下面
<%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("暫時(shí)無該記錄")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("?")''如果字段比較多,繼續(xù)添加新個(gè)表格行來顯示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%>

參數(shù)說明:showpros(tablename,topnum,fildname,loopnum,typenum)
whichpro為選擇何類型的產(chǎn)品種類
topnum表示提取多少條記錄
fildname表示調(diào)試顯示的字段,具體應(yīng)用的時(shí)候可以省去該參數(shù),在函數(shù)內(nèi)部直接使用
loopnum表示顯示的循環(huán)每行的記錄條數(shù)
typenum表示循環(huán)顯示的方法:目前分了兩類,橫向并列、縱向并列顯示同一數(shù)據(jù)記錄行的不同記錄

引用示例如下:
<%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)%>

? ? ? 以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助~如果有疑問大家可以留言交流,謝謝大家對錯(cuò)新技術(shù)頻道的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 龙川县| 上饶县| 石河子市| 图木舒克市| 深泽县| 南阳市| 三河市| 奉节县| 进贤县| 黄龙县| 潍坊市| 高安市| 慈利县| 馆陶县| 三穗县| 肥乡县| 都匀市| 隆林| 邯郸县| 丰顺县| 昔阳县| 壶关县| 邻水| 望奎县| 石家庄市| 双峰县| 滦南县| 宝兴县| 双辽市| 轮台县| 卓资县| 成安县| 扬中市| 米林县| 凤山市| 峨山| 汤原县| 海南省| 维西| 寻甸| 海兴县|