|
-
Oct 27th, 2004, 11:37 PM
#1
Thread Starter
Member
ASP: Your Last Visit Is On...???
ASP CODE:
How to do this kind of extra information for the user?
Your Last Visit On This Page Is On: ......???
-
Oct 28th, 2004, 01:21 AM
#2
-
Oct 28th, 2004, 02:13 AM
#3
Fanatic Member
http://www.w3schools.com/asp/asp_cookies.asp
Or store the information in a database along with their ip address, but is it really usefull information?
-
Oct 28th, 2004, 10:54 PM
#4
Thread Starter
Member
Hai all...
I have been trying to do this code but I cannot make it works!
Could you help debugging the code...I dont know if the code is in the correct syntax or not!
I place this code at the top of all my page to check an invalid user that are trying to access the page without logging in!
When they are success, I want to update a field to store the current time ("LastActive" field)
When the user login, I ask for their Username and password!
and then, reffering to this username, update the LastActive field!
I dont know how to peform the UPDATE function.
Could sombody help me?
Code:
<%@LANGUAGE="VBSCRIPT"%>
<% Option Explicit %>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
If Session("admin") = "" Then
Response.Redirect("session_ended.asp")
else
Dim conn,admin,rightnow,user
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("database\users.mdb"))
set admin = Server.CreateObject("ADODB.recordset")
user=Request.Form("txtusername") <%--txyusername is an input username in the login page-->
rightnow = Now()
admin.open "UPDATE userlist SET LastActive = " & rightnow & " WHERE username = " & user & ""
end if
%>
<html>
<head>
..
..
..
-
Oct 31st, 2004, 04:21 AM
#5
Assuming the rest of your code is right,
conn.Execute "UPDATE userlist SET LastActive = '" & rightnow & "' WHERE username = '" & user & "'"
HTH
-
Oct 31st, 2004, 09:31 PM
#6
Thread Starter
Member
so thats mean...
I remove the admin.open and replace them with conn.execute?
Initial...
admin.open "UPDATE userlist SET LastActive = " & rightnow & " WHERE username = " & user & ""
Replace with...???
conn.Execute "UPDATE userlist SET LastActive = '" & rightnow & "' WHERE username = '" & user & "'"
Let me try them first...Thanx
Last edited by monie; Oct 31st, 2004 at 09:38 PM.
-
Oct 31st, 2004, 11:47 PM
#7
First, a small explanation. The admin.open line was not working because you did not specify a connection to use. So it should have looked like
admin.open, strSQLQuery, conn
But, since your sql does not return any rows, there's no point in using the recordset there. Better use the connection object to execute it directly against the database.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|