Forums
This topic is locked
Urgent HELP - Record Login Date into SQL
29 Jun 2006 13:05:44 YC ong posted:
Hi All,I want to record the login date into SQL after verify the username and password. But My Login page just can update the login date at 1st time login only. Then after that, i can't update the login date into sql already. I can only update the login date again after close the internet explorer and login again.
I'm fresh in ASP VB script, so I really do not know how to amend my code.
Hope someone can help because I am urgent need it work....
My login page's code is as below:
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL"
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername=CStr(Request.Form("txtUserName"
If MM_valUsername <> "" Then
MM_fldUserAuthorization="AccessLevel"
MM_redirectLoginSuccess="Home.asp"
MM_redirectLoginFailed="loginUnsuccessful.asp"
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_InternalWeb_STRING
MM_rsUser.Source = "SELECT UserName, Password"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM dbo.UserDetail WHERE UserName='" & Replace(MM_valUsername,"'","''"
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"
If (MM_fldUserAuthorization <> ""
Session("MM_UserAuthorization"
Else
Session("MM_UserAuthorization"
End If
if CStr(Request.QueryString("accessdenied"
MM_redirectLoginSuccess = Request.QueryString("accessdenied"
End If
strSQL="UPDATE UserDetail set loginDt=getdate() where UserName='" & Session("MM_Username"
set Update = Server.CreateObject("ADODB.Command"
Update.ActiveConnection = MM_InternalWeb_STRING
Update.CommandText=strSQL
Update.Execute
Update.ActiveConnection.Close
set Update=nothing
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
set MM_rsUser=nothing
Response.Redirect(MM_redirectLoginFailed)
End If
%>
Hope someone can help? Thanks in advance.
Replies
Replied 30 Jun 2006 02:10:32
30 Jun 2006 02:10:32 micah santos replied:
i'll work on this thing out later.
Replied 30 Jun 2006 04:01:32
30 Jun 2006 04:01:32 YC ong replied:
TQ in advance!
YC Ong
YC Ong
Replied 14 Jul 2006 08:44:27
14 Jul 2006 08:44:27 YC ong replied:
Hi,
My code is no problem and I settled my problem. Thanks.
My code is no problem and I settled my problem. Thanks.
