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,___________________________________________________________________________________________________________________________________
最新评论
本站CDN与莫名CDN同款、亚太CDN、速度还不错,值得推荐。
感谢推荐我们公司产品、有什么活动会第一时间公布!
我在用这类站群服务器、还可以. 用很多年了。