ASP CODE:
How to do this kind of extra information for the user?
Your Last Visit On This Page Is On: ......???
Printable View
ASP CODE:
How to do this kind of extra information for the user?
Your Last Visit On This Page Is On: ......???
Cookies.
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?
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>
..
..
..
Assuming the rest of your code is right,
conn.Execute "UPDATE userlist SET LastActive = '" & rightnow & "' WHERE username = '" & user & "'"
HTH
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
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.