Results 1 to 7 of 7

Thread: ASP: Your Last Visit Is On...???

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    malaysia
    Posts
    57

    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: ......???

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Cookies.

  3. #3
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727
    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?

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    malaysia
    Posts
    57
    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>
    ..
    ..
    ..

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Assuming the rest of your code is right,


    conn.Execute "UPDATE userlist SET LastActive = '" & rightnow & "' WHERE username = '" & user & "'"



    HTH

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    malaysia
    Posts
    57
    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.

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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
  •  



Click Here to Expand Forum to Full Width