CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 How do I update a field upon login in

Print topic Send  topic

Author Message
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

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.