Vincent
Posts: 31
|
Posted: 09/21/2008, 11:38 PM |
|
Here is what I've done. On your login page add a server On_Click event to the login button of the form (Button_DoLogin). You will need to create a table in your database in my case I called it Tbl_Retailer_Login_History. Modify the code below to your needs and it should do what you are looking for.
'Login @4-3D04C4CB
With Login
If NOT CCLoginUser(.login.Value, .password.Value) Then
.Errors.addError(CCSLocales.GetText("CCS_LoginError", Empty))
Login_Button_DoLogin_OnClick = False
.password.Value = ""
Else
If Not IsEmpty(CCGetParam("ret_link", Empty)) Then _
Redirect = CCGetParam("ret_link", Empty)
'Set up DB Connection
Dim DBConn, Ret_Nom, rsRet_Name, sql
Set DBConn = new clsDBRMCCcon
'Update the Retailer_Last_login field in Tbl_Retailers
DBConn.Open
DBConn.Execute "UPDATE tbl_Retailers SET Retailer_Last_Login='" + Cstr(now) + "'" + "WHERE Retailer_Email = '" + .login.Value + "'"
'DBConn.Close
'End of Update the Retailer_Last_login field in Tbl_Retailer
'add each login activity to tbl_Retailer_Login_History
'DBConn.Open
sql = "SELECT Retailer_Name FROM tbl_Retailers where Retailer_Email ='" + .login.Value + "'"
Set rsRet_Name = DBConn.Execute(sql)
' Loop through the Retailer table.
if not rsRet_Name.EOF then
Ret_Nom = rsRet_Name("Retailer_Name")
else
Ret_Nom = "Error...."
end if
rsRet_Name.close
set rsRet_Name = nothing
'DBConn.Close
'DBConn.Open
DBConn.Execute "INSERT INTO tbl_Retailer_Login_History (Ret_Name,Ret_Email,Login_Date,Login_Used) VALUES (" + "'" + Ret_Nom + "','" + .login.Value + "','" + Cstr(now) + "','" + .login.Value + "'" + ")"
DBConn.Close
' End of add each login activity to tbl_Retailer_Login_History
Set DBConn = nothing
' End of DB Connection
Login_Button_DoLogin_OnClick = True
End If
End With
'End Login
Hope this helps,
Vincent
|
csierra
Posts: 123
|
Posted: 09/22/2008, 2:35 AM |
|
Thanks for that share, I am going to play around with (obviously) conn string and with SQL in orther to UPDATE FIRST as to rather than log into log many times the same user, just the last time that user was loged into the system, have to run an additional query to check if it is already there, if it is not, then to do an INSERT INTO rather.
Thanks again
_________________
Yes! I Can!!! |