navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Login Needs to Generate Timestamp

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Login Needs to Generate Timestamp
Page: [1]
 
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!!!
Spooky

 

Posts: 26559
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Login Needs to Generate Timestamp - 5/6/2008 16:01:15   
You would need to insert (as a minimum) the UserID, the tableID and the time into a new table so that multiple user records could be stored.

It should be as simple as a unique insert when the user enters the page within one session

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to jheun)
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

(in reply to Spooky)
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?

(in reply to Spooky)
Spooky

 

Posts: 26559
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Login Needs to Generate Timestamp - 5/11/2008 16:31:08   
Any asp script will do - all you are doing, is storing the date/time and the username in a new table at the same time they login.
The script would be processed within the same page.

eg
"INSERT INTO LOGIN_TABLE (Username,LoginTime) VALUES ('"&username&"', '"&Now()&"')

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to jheun)
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.

(in reply to Spooky)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Login Needs to Generate Timestamp
Page: [1]
Jump to: 1





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