Nicolas
|
Posted: 01/31/2002, 10:55 AM |
|
I am trying to write the current date to a field in the users table when a user logs in (so that I know when the last update was made).
Can anybody please tell me how this can be done (with ASP and MS Access)? I suppose it is through an SQL statement using the now() function like
SQLu = update users set lastupdate=now() where ?
cn.execute SQLu
but all my tries have lead to errors and I don't know what to use for where (never used SQL langage before)???
|
|
|
Ken Hardwick
|
Posted: 01/31/2002, 12:11 PM |
|
Add the code below to your After-Login Event
Table = Users
Field for Login ID = Login
Field for login date = Login_Date
Also, added count field to keep track of times logged in
Login_Count
This executes only if login/password are valid..if bpassed= 0
The sLogin is temporary variable of loginid entered.
'***********************************************************************
if bPassed > 0 then
sWhere = "Login= " & toSQL(sLogin,"Text")
sSQL = "update USERS set " & _
"LOGIN_DATE = now " & _
",LOGIN_COUNT = LOGIN_COUNT + 1 "
sSQL = sSQL & " where " & sWhere
response.write sSQL
cn.execute sSQL
end if
|
|
|
Chris
|
Posted: 03/05/2002, 11:27 AM |
|
Hi Ken,
Thanks for this code... I had to make a few changes because my USERS table is called MEMBERS but otherwise everything is the same. I placed it in the ON LOGIN event part of the login FORM (of the login page)... the code is working because it changing my database, but I"m getting the following error (any ideas???):
update MEMBERS set last_login_date = now , login_count = login_count + 1 where member_login= 'admin'
Response object error 'ASP 0156 : 80004005'
Header Error
/portal/Login.asp, line 155
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
|
|
|
Erick Souza Ribeiro
|
Posted: 01/13/2003, 9:21 PM |
|
I insert this code in custom login session from login page form
the error happened because there was missing a remark before the 'response.write sSQL
'-------------------------------
sLogin = GetParam("Login")
sPassword = GetParam("Password")
bPassed = CLng(DLookUp("IdentificacaoDoUsuario", "count(*)", "Username =" & ToSQL(sLogin, "Text") & " and Senha=" & ToSQL(sPassword, "Text")))
if bPassed > 0 then
sWhere = "Username= " & toSQL(sLogin,"Text")
sSQL = "Update IdentificacaoDoUsuario set " &_
"UltimoAcessoData=now " &_
",LoginCount = LoginCount + 1 "
sSQL = sSQL & " where " & sWhere
'response.write sSQL
cn.execute sSQL
end if
if bPassed > 0 then
'-------------------------------
' Login and password passed
'-------------------------------
Session("UserID") = CStr(DLookUp("IdentificacaoDoUsuario", "User_id", "Username =" & ToSQL(sLogin, "Text") & " and Senha=" & ToSQL(sPassword, "Text")))
Session("UserRights") = CLng(DLookUp("IdentificacaoDoUsuario", "Nivel", "Username =" & ToSQL(sLogin, "Text") & " and Senha=" & ToSQL(sPassword, "Text")))
cn.Close
Set cn = Nothing
if not(sPage = request.serverVariables("SCRIPT_NAME")) and not(isEmpty(sPage)) then
response.redirect(sPage & "?" & sQueryString)
end if
response.redirect("LocalizarUsuario.asp")
else
sloginErr = "Usuario ou senha incorretos."
end if
'-------------------------------
Regards
|
|
|
|