| sub cmdTijiao_onClick() if frmRes.txtNum.value=”” or frmRes.txtPasswd.value=”” or (Not IsNumeric(frmRes.txtNum.value)) then Alert”請(qǐng)?jiān)趲ぬ?hào)和密碼中輸入相應(yīng)的內(nèi)容,帳號(hào)必須為數(shù)字!” else frmRes.submit end if end sub |
| sub cmdTijiao_onClick() if Not Numeric(frmNew.txtNum.value) or frmNew.txtPasswd.value<>frmNew.txtConfirm.value then Alert”輸入不正確,請(qǐng)重新輸入!” else frmNew.submit end if end sub |
| <html><head> <meta http-equiv=”Content-Type” content=”text/html;charset=gb2312″> <meta name=”GENERATOR” content=”Microsoft Fronpage 3.0″> <titile>注冊(cè)判斷</title></head> <body><% Num=Request.form(“txtNum”) “把前面窗口傳送來(lái)的內(nèi)容賦給Num和Passwd兩個(gè)字符串。 Passwd=Request.form(“txtPasswd”) dbname=”Driver={Microsoft Access Driver(*.mdb)};DBQ=”&Server.MapPath(“”)”&”ResDbRes.mdb;” “dbname是打開數(shù)據(jù)庫(kù)要用的 set Cres=Server.CreateObject(“ADODB.Connection”) “以下是利用Connection對(duì)像和Recordset對(duì)象聯(lián)結(jié)數(shù)據(jù)庫(kù)并查找的代碼。 set res=Server.CreateObject(“ADODB.Recordset”) Cres.open dbname res.ActiveConnection=Cres res.source=”Select*from res where 帳號(hào)=”&Num&” and 密碼=”&Passwd&”;” res.open if res.BOF then “如果查找結(jié)果為空,那么就說(shuō)明注冊(cè)不正確,所以在頁(yè)面中顯示下面的文本/ %><p>注冊(cè)不正確, 請(qǐng)返回注冊(cè)頁(yè)面重新注冊(cè)!</p> <% else “否則就說(shuō)明注冊(cè)成功,可以進(jìn)入瀏覽頁(yè)面! %> <!–#Include virtual=”/success.htm”–> “這里采用了Server Side Include的方法,把允許瀏覽的頁(yè)面包含在這個(gè)文件里面! <% res.Close “ 關(guān)閉剛才打開的數(shù)據(jù)庫(kù)。 end if %> </body></html> |
| <html> <head> <meta http-equiv=”Content-Type” content=”text/html;charset=gb2312″> ?。糾eta name=”GENERATOR” content=”Microsoft frontpage 3.0″> ?。紅itle>輸入數(shù)據(jù)庫(kù)</title> </head> <body> <!–#Include virtual=”/adovbs.inc”> “這個(gè)被包含進(jìn)來(lái)的文件adovbs.inc是定義數(shù)據(jù)庫(kù)對(duì)象ADO常量的文件。 <% Num=Request.form(“txtNum”) “把前面主頁(yè)傳送過(guò)來(lái)的內(nèi)容賦給Num和Passwd兩個(gè)變量。 Passwd=Request.form(“txtPasswd”) Set res=Server.CreateObject(“ADODB.Recordset”) “打開數(shù)據(jù)庫(kù)。 dbname=”Driver={Microsoft Access Driver(*.mdb)};DBQ=”&ServerMapPath(“”)&”ResDbRes.mdb;” sql=”select*from res” res.open sql,dbName,adOpenKeyset,adLockOptimistic res.AddNew “添加新紀(jì)錄 res(1)=Num “res(1)代表數(shù)據(jù)庫(kù)中的第二個(gè)字段,存儲(chǔ)的是用戶的帳號(hào)。 res(2)=Passwd “res(2)代表數(shù)據(jù)庫(kù)中的第三個(gè)字段,存儲(chǔ)的是用戶的密碼。 res.Update “更新數(shù)據(jù)庫(kù)/ res.Close %> ?。紁><b><font face=楷體_gb2312 size=5>您的帳號(hào)和密碼已經(jīng)注冊(cè)成功,您現(xiàn)在可以<a href=”http://your/index.htm”>進(jìn)入</a>了?。?font></p> </body></html> |