Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One way to set back database counter back to ZERO

Dreamweaver & Flash

One way to set back database counter back to ZERO

by  CDN  Posted    (Edited  )
[color navy]I have set up a page with a login counter that increments by 1 everytime a user fails to log in, either because he\she forgets the password or leaves the field blank.
Basically what I did was set my counter to reach 3 tries and then lock them out (then they would have to call a number to get unlocked) So, [color blue]schase's[/color] help who credits Link9 for his help to him, I was able to come up with this version on how to do it. I know this may not be the best way but it's working for me.
Those familiar with DreamWeaver will recognize the coding and I will color-code the areas that actually made this page work for me. I hope this really helps someone in the near future.[/color]

[tt]
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Request.QueryString
MM_valUsername=CStr(Request.Form("username"))
If MM_valUsername <> "" Then
MM_fldUserAuthorization=""
MM_redirectLoginSuccess="page1.asp"
MM_redirectLoginFailed="login.asp"
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_mydsn_STRING
MM_rsUser.Source = "SELECT account, password"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
[color green] MM_rsUser.Source = MM_rsUser.Source & " FROM dbo.mydatabase WHERE account='" & MM_valUsername &"' AND password='" & CStr(Request.Form("password")) & "' and counter < 3"[/color]
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
Session("MM_Password") = CStr(Request.Form("password"))
[color blue]dim sql
set sql = server.createobject("adodb.recordset")
sql.open "UPDATE mydatabase SET counter=0 WHERE account = '" & session("MM_username") & "'" , "dsn=mydsn;uid=me;pwd=cdn;"[/color]

If (MM_fldUserAuthorization <> "") Then
Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization") = ""
End If
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")
[/tt]



Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top