[SOLVED] User Last Visit Status

This is a discussion on "[SOLVED] User Last Visit Status" within the Classic ASP section. This forum, and the thread "[SOLVED] User Last Visit Status are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Oct 2nd, 2007, 02:59
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,609
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
[SOLVED] User Last Visit Status

I have this code with me since 1 years ago that are still not working.

It is about updating/setting a LastVisit date on the userlist table on my database.
If the user successfully logged on to my page, the LastVisit field in my userlist table will be updated with the current date and time.

Here is the flow of my login page:

login.asp(login form) > verify.asp(login verification) > protectedpage.asp(successfull login)

I do the update database process in my protectedpage.asp and here is the code:

Code: Select all
<%@LANGUAGE="VBSCRIPT"%>
<% Option Explicit %> 
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

If Session("name") = "" Then
    Response.Redirect("login.asp")
else
    Dim conn,login,rightnow,user
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open(Server.MapPath("db/users.mdb"))
    set login = Server.CreateObject("ADODB.Recordset")
    
    user = Request.Form("txtusername")
    rightNow = Now()
    login.open "UPDATE userlist SET LastActive = " & rightnow & " WHERE username = " & user & ""
End If
%>

<head>
<title>LOGIN</title>
</head>
<Body>
YOUR LOGIN IS SUCCESS!
THIS IS A PROTECTED PAGE!
</Body>
</html>
Error Message:
Code: Select all
Error Type:
 ADODB.Recordset (0x800A0E7D)
The connection cannot be used to perform this operation. It is either closed or invalid in this context.
/protectedpage.asp, line 19 
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Oct 2nd, 2007 at 03:03.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 2nd, 2007, 09:15
Up'n'Coming Member
Join Date: Sep 2007
Location: Wales, UK
Age: 36
Posts: 88
Thanks: 1
Thanked 0 Times in 0 Posts
Re: User Last Visit Status

Looks like the connection string is not valid, i would rem out the update statement and just do a simple select statement and display a single field on the page.

also look here for more pointers - http://tutorials.aspfaq.com/8000xxxx...7d-errors.html

Additionally i would not call a session variable "name" as it is a reserved name, i would suggest you use a naming convention for all session variables like "svName".

Last edited by robbied72; Oct 2nd, 2007 at 09:18.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 2nd, 2007, 09:20
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,609
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: User Last Visit Status

Thanks robbied, let me have a look at it tonight.

Thanks.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 10th, 2007, 03:03
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,609
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: User Last Visit Status

I changed the way I connect to the database and the way I connect to my recordset and...
walla! I've don it!

Code: Select all
<%
    Dim connection,rec,rightnow,user
    rightnow = now()
    user = Session("svName")
    
    <!-- Update statement according to the username from session variable -->
    Set connection = Server.CreateObject("ADODB.Connection")
    connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("db/users.mdb")
    Set rec = connection.Execute("UPDATE userlist SET status = 'Offline', lastactive = '" & rightnow & "' WHERE username =  '" & user & "'")

    Session.Abandon
    Response.Redirect("index.asp")
%>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] User Location Monie Classic ASP 3 Jan 8th, 2008 00:55
[SOLVED] Status bar - Firefox alexgeek Scripts and Online Services 2 Jan 3rd, 2008 01:32
[SOLVED] Your last visit is Today?? Monie Classic ASP 27 Nov 1st, 2007 04:16
[SOLVED] Show "Image" Depends On User "Status"? Monie Classic ASP 6 Oct 16th, 2007 01:22
Display User Status? Monie Classic ASP 17 Oct 29th, 2004 04:18


All times are GMT. The time now is 19:58.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42