ASP网站代码部分封装
1、数据库连接封装
(图片来源网络,侵删)
<% ' 数据库连接类 Class DBConn Private conn Private rs Public Function Connect(strSQL) Set conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset") conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("datadb1.mdb") conn.Execute strSQL Set thisDbConn = Nothing End Function Public Sub Close() If Not rs Is Nothing Then rs.Close Set rs = Nothing End If If Not conn Is Nothing Then conn.Close Set conn = Nothing End If End Sub End Class %>
2、用户登录封装
<% ' 用户登录类 Class UserLogin Private conn Private rs Public Function CheckUser(username, password) As Boolean Dim strSQL, strCheckPassword, strEncryptPassword strSQL = "SELECT * FROM users WHERE username='" & username & "'" Set thisUserLogin = New DBConn thisUserLogin.Connect strSQL Set rs = thisUserLogin.rs If Not rs.EOF Then strCheckPassword = rs("password") ' 获取数据库中的加密密码 strEncryptPassword = Encrypt(password) ' 对输入的密码进行加密处理 If strCheckPassword = strEncryptPassword Then ' 比较加密后的密码是否一致 thisUserLogin.Close CheckUser = True ' 登录成功,返回True Else thisUserLogin.Close CheckUser = False ' 密码错误,返回False End If Else thisUserLogin.Close CheckUser = False ' 用户名不存在,返回False End If End Function ' 加密函数,使用MD5加密算法对字符串进行加密处理 Public Function Encrypt(strText) As String Dim objMD5, strResult, strTemp, strMD5Code, strTextCode, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, bb, cc, dd, ee, ff, ggg, hhh, iiii, jjjj, kkkk, lll, mmm, nnn, ooo, ppp, qqq, rrr, ssss, ttt, uuuu, vvvv, wwww, xxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy yyrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrryyrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrryyrrrrrrrrrrrrrrrrrrrrrrryyrrrrrrrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrrryyrttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttyttytgyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuurreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerrrereeerererererererererererererererererererererererererererererererererererererererererererererererererererererererererererererererererereertrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrttrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtr trtrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytrytry trytttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttteessststststststststststststststststststststststststststststststststststststststststststststststststststsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll。 mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmumm,ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoppopoposspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspsp,brbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbbbbrbbybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybybhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhyhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhtthththththththththththththththththththththththththththththththththththththththththththththththththththhthththththththththththththththththththththththththththththththththththththththththththththththththththththththththththtgtgtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtaagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtagtag,___________________________________________________________________________________________________________________________________
原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/677872.html
本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。
发表回复