用Dreamweaver建网站如何实现用户登录和注册?以及访问权限?
2个回答
2013-06-22
展开全部
这是我写的部分验证的方法Sub chklogin()
Dim Rs,SQL
Dim adminname, password,RandomCode
adminname = Newasp.CheckBadstr(Request("adminname"))
password = md5(Trim(Replace(Request("password"), "'", "")),16)
If NewAsp.ChkPost = False Then
ErrMsg = ErrMsg + "您提交的数据不合法,请不要从外部提交登陆!"
Founderr = True
End If
If Len(adminname) = 0 Then
ErrMsg = ErrMsg + "用户名不能为空!"
Founderr = True
End If
If Len(Request("password")) = 0 Then
ErrMsg = ErrMsg + "用户密码不能为空!"
Founderr = True
End If
If IsAdminValidate Then
If Trim(Request.Form("validate")) <> AdminValidateCode Or Trim(Request.Form("validate")) = "" Then
ErrMsg = ErrMsg+"<li>您输入的认证码或者密码错误,请重新输入!</li>"
Founderr = True
Exit Sub
End if
End If
If IsAdminCheckCode Then
If Not NewAsp.CodeIsTrue Then
ErrMsg = ErrMsg + "<br>" + "<li>您输入的认码和系统产生的不一致,请重新输入!</li>"
Founderr = True
Exit Sub
End If
End If
If Founderr = True Then Exit Sub
If Not IsObject(Conn) Then ConnectionDatabase
Set Rs = NewAsp.CreateAXObject("ADODB.Recordset")
SQL = "SELECT * FROM NC_Admin WHERE password='" & Replace(password, "'", "''") & "' And username='" & adminname & "'"
Rs.Open SQL, Conn, 1, 3
If Rs.BOF And Rs.EOF Then
FoundErr = True
ErrMsg = ErrMsg + "<li>您输入的用户名和密码不正确或者您不是系统管理员。!</li>"
Exit Sub
Else
If Rs("isLock") <> 0 Or Rs("isLock") = "" Then
Founderr = True
ErrMsg = "<li>你的用户名已被锁定,你不能登陆!如要开通此帐号,请联系管理员。</li>"
Exit Sub
End If
RandomCode = NewAsp.GetRandomCode(16)
Rs("LoginTime") = Now()
Rs("Loginip") = NewAsp.UserTrueIP
Rs("RandomCode") = RandomCode
Rs.Update
If FoundErr = False Then
Session(AdminSessionName & "_AdminName") = Rs("username")
Session(AdminSessionName & "_AdminPass") = Rs("password")
Session(AdminSessionName & "_AdminGrade") = Rs("AdminGrade")
Session(AdminSessionName & "_Adminflag") = Rs("Adminflag")
Session(AdminSessionName & "_AdminStatus") = Rs("Status")
Session(AdminSessionName & "_AdminRandomCode") = RandomCode
Session(AdminSessionName & "_AdminID") = Rs("id")
Session.Timeout=45
If IsAdminValidate Then
Session(AdminSessionName & "_validate") = Trim(Request.Form("validate"))
End If
If UseAdminCookies Then
Response.Cookies(AdminCookiesName).path = "/"
Response.Cookies(AdminCookiesName)("AdminName") = Rs("username")
Response.Cookies(AdminCookiesName)("AdminPass") = Rs("password")
Response.Cookies(AdminCookiesName)("AdminGrade") = Rs("AdminGrade")
Response.Cookies(AdminCookiesName)("Adminflag") = Rs("Adminflag")
Response.Cookies(AdminCookiesName)("AdminStatus") = Rs("Status")
Response.Cookies(AdminCookiesName)("RandomCode") = RandomCode
Response.Cookies(AdminCookiesName)("AdminID") = Rs("id")
If IsAdminValidate Then
Response.Cookies(AdminCookiesName)("validate") = Trim(Request.Form("validate"))
End If
End If
End If
End If
Rs.Close:Set Rs = Nothing
Response.Redirect("admin_index.asp")
End Sub
Dim Rs,SQL
Dim adminname, password,RandomCode
adminname = Newasp.CheckBadstr(Request("adminname"))
password = md5(Trim(Replace(Request("password"), "'", "")),16)
If NewAsp.ChkPost = False Then
ErrMsg = ErrMsg + "您提交的数据不合法,请不要从外部提交登陆!"
Founderr = True
End If
If Len(adminname) = 0 Then
ErrMsg = ErrMsg + "用户名不能为空!"
Founderr = True
End If
If Len(Request("password")) = 0 Then
ErrMsg = ErrMsg + "用户密码不能为空!"
Founderr = True
End If
If IsAdminValidate Then
If Trim(Request.Form("validate")) <> AdminValidateCode Or Trim(Request.Form("validate")) = "" Then
ErrMsg = ErrMsg+"<li>您输入的认证码或者密码错误,请重新输入!</li>"
Founderr = True
Exit Sub
End if
End If
If IsAdminCheckCode Then
If Not NewAsp.CodeIsTrue Then
ErrMsg = ErrMsg + "<br>" + "<li>您输入的认码和系统产生的不一致,请重新输入!</li>"
Founderr = True
Exit Sub
End If
End If
If Founderr = True Then Exit Sub
If Not IsObject(Conn) Then ConnectionDatabase
Set Rs = NewAsp.CreateAXObject("ADODB.Recordset")
SQL = "SELECT * FROM NC_Admin WHERE password='" & Replace(password, "'", "''") & "' And username='" & adminname & "'"
Rs.Open SQL, Conn, 1, 3
If Rs.BOF And Rs.EOF Then
FoundErr = True
ErrMsg = ErrMsg + "<li>您输入的用户名和密码不正确或者您不是系统管理员。!</li>"
Exit Sub
Else
If Rs("isLock") <> 0 Or Rs("isLock") = "" Then
Founderr = True
ErrMsg = "<li>你的用户名已被锁定,你不能登陆!如要开通此帐号,请联系管理员。</li>"
Exit Sub
End If
RandomCode = NewAsp.GetRandomCode(16)
Rs("LoginTime") = Now()
Rs("Loginip") = NewAsp.UserTrueIP
Rs("RandomCode") = RandomCode
Rs.Update
If FoundErr = False Then
Session(AdminSessionName & "_AdminName") = Rs("username")
Session(AdminSessionName & "_AdminPass") = Rs("password")
Session(AdminSessionName & "_AdminGrade") = Rs("AdminGrade")
Session(AdminSessionName & "_Adminflag") = Rs("Adminflag")
Session(AdminSessionName & "_AdminStatus") = Rs("Status")
Session(AdminSessionName & "_AdminRandomCode") = RandomCode
Session(AdminSessionName & "_AdminID") = Rs("id")
Session.Timeout=45
If IsAdminValidate Then
Session(AdminSessionName & "_validate") = Trim(Request.Form("validate"))
End If
If UseAdminCookies Then
Response.Cookies(AdminCookiesName).path = "/"
Response.Cookies(AdminCookiesName)("AdminName") = Rs("username")
Response.Cookies(AdminCookiesName)("AdminPass") = Rs("password")
Response.Cookies(AdminCookiesName)("AdminGrade") = Rs("AdminGrade")
Response.Cookies(AdminCookiesName)("Adminflag") = Rs("Adminflag")
Response.Cookies(AdminCookiesName)("AdminStatus") = Rs("Status")
Response.Cookies(AdminCookiesName)("RandomCode") = RandomCode
Response.Cookies(AdminCookiesName)("AdminID") = Rs("id")
If IsAdminValidate Then
Response.Cookies(AdminCookiesName)("validate") = Trim(Request.Form("validate"))
End If
End If
End If
End If
Rs.Close:Set Rs = Nothing
Response.Redirect("admin_index.asp")
End Sub
2013-06-22
展开全部
楼主可以先了解一下 PHP、.NET、JSP、ASP等语言,用这些就可以实现楼主想用的功能~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询