|
| |
|
|
jheun
Posts: 4 Joined: 5/5/2008 Status: offline
|
Login Needs to Generate Timestamp - 5/5/2008 21:36:14
I have developed a log in page that parses information from a database of user ids and passwords. I need that page to automatically send a timestamp, upon a successful login, of when that user logged in to a table within that database. Any help with sample code is greatly appreciated!!!
|
|
|
|
DesiMcK
Posts: 405 Joined: 4/26/2004 From: Essex, UK Status: offline
|
RE: Login Needs to Generate Timestamp - 5/6/2008 17:32:13
I have used this code in the past dim fs,f set fs=Server.CreateObject("Scripting.FileSystemObject") set f=fs.OpenTextFile(Server.MapPath("UserLog.txt"),8,true) f.WriteLine("UserName: " & strUserName1 & ", Password: VALID, Date and Time: " &MediumDate(FormatDateTime(Now)) & " - " & FormatDateTime(Now,4)) & ", IP=" & Request.ServerVariables("REMOTE_ADDR") & ", USER_AGENT=" & Request.ServerVariables("HTTP_USER_AGENT") f.Close set f=Nothing set fs=Nothing It writes the details to a text file called UserLog.txt Desi
|
|
|
|
jheun
Posts: 4 Joined: 5/5/2008 Status: offline
|
RE: Login Needs to Generate Timestamp - 5/11/2008 15:21:51
Spooky, Thank you for the information. I don't think I clearly explained my situation. I want the timestamp to be written to a table automatically upon the user login. Is there a script you can provide me with that does this?
|
|
|
|
jheun
Posts: 4 Joined: 5/5/2008 Status: offline
|
RE: Login Needs to Generate Timestamp - 5/11/2008 17:31:41
Thanks, Spooky. At the risk of sounding like a total noob, I don't know how to write it so it works. I am sort of new to do this. Here is the code of the page: <body bgcolor="#003366"> <% 'Connection String Dim Conn 'Query to be executed Dim SQLQuery 'Recordset Dim rs 'StudentNo Of Logged in user Dim UserName 'Password of User Dim Password 'Getting information from submitted form UserName = request.form("username") Password = request.form("password") RememberMe = request.form("rememberme") 'If not blank Username password submitted if UserName <> "" or Password <> "" then 'Creating connection Object set Conn=server.createobject("ADODB.Connection") 'Creating Recordset Object set rs = Server.CreateObject("ADODB.Recordset") 'Initialising Provider String connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" connStr = connStr + server.MapPath("fpdb/mhswimclub.mdb") 'Opening Connection to Database Conn.open connStr 'Query to be executed SQLQuery = "select * from members where lastname = '"&UserName&"' AND memberid = '"&Password&"'" 'Retrieving recordset by executing SQL set rs=Conn.execute(SQLQuery) 'If no records retrieved if rs.BOF and rs.EOF then Response.Redirect "login.asp?username=" & UserName else 'If remember me selected if RememberMe = "ON" then 'Writing cookies permanently Response.Cookies("UserName")=UserName Response.Cookies("Password")=Password Response.Cookies("UserName").Expires = Now() + 365 Response.Cookies("Password").Expires = Now() + 365 Response.Redirect "welcome.asp" else 'writing cookies temporarily Response.Cookies("UserName")=UserName Response.Cookies("Password")=Password Response.Redirect "welcome.asp" end if 'Closing all database connections Conn.Close rs.close set rs = nothing set Conn = nothing end if else 'Invalid User Response.Redirect "login.asp?UserName=blank" end if %> --Thank you for your valuable time.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|