CodeCharge Studio
search Register Login  

Visual PHP Web Development

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

YesSoftware Forums -> CodeCharge Studio -> ASP

 Login Log?

Print topic Send  topic

Author Message
csierra

Posts: 123
Posted: 09/16/2008, 8:58 PM

Does anyone have an already made function to log every user that logs and keep log in dat time?

Thanks
_________________
Yes! I Can!!!
View profile  Send private message
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
View profile  Send private message
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!!!
View profile  Send private message

Add new topic Subscribe to topic   


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

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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