Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Closed Thread
 
LinkBack Thread Tools
Old October 11th, 2004, 10:54 PM   #1
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Display User Status?

Hello everybody....

Its been so long since I tried to know the method used to display the status of the user that are currently online.
Is if involves a compleks programming to do this?

I am developing an INTRANET web system for my university.
I want to display the status of each user that have Registered/Logged On to the system by displaying the ONLINE or OFFLINE status.
Just like webforumz have used...:razz:

I have a page that will display all the list of the registered user,
at the end of each row, i want to display the ONLINE of OFFLINE status!

Can anybody give me a lecture on this...lol
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 12th, 2004, 05:44 AM   #2
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
Hi monie...

This will involve having an extra field in your database... something like member_LastActive.

Every time they hit a page on the intranet, you should update the field with the current date/time (use the now() function).

On you members page, you can simply query this field for each member... if the value is less than 10 or 15 minutes ago (or whatever period you think) then the user is online.

Hope this makes sense.
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 12th, 2004, 07:24 AM   #3
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Hemm......
I dont really understand the method!
If you have time, can you explain it to me further more
Thanx Rob.
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 12th, 2004, 07:30 AM   #4
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
How does a user login right now?? He/she fills in a form and submits it right? You check the details he/she provided and validate them against your database..... right?

When displaying a page, how do you make sure you only show it to a member?
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 12th, 2004, 09:43 PM   #5
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Ok...let me start!
First of all, because my system will be used by quiet small numbers of user and for security purpose, the admin will provide a username and password to the user (in my case the lecturer, the only user to my system)
The information of the user (username & password) will be kept inside a database called userList.mdb

When they get their password and their username, they can logon to the system. All the validation I have successfully done.
(Invalid user, invalid password, invalid username...)

After they have successfully logged on to the system, there is a page where they can post their comment or complaint and later it will be display just like what webforumz do(like this page), at the bottom of their message, there will be an indicator indicating that they are online or offline.

so...do you follow me
thank for helping me Rob
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 13th, 2004, 02:57 AM   #6
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
Everytime the lecturer hits a page, are you checking it IS in fact the lecturer? In other words, do you check for a valid login on each page he hits?
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 13th, 2004, 08:09 AM   #7
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Hai Rob,
Actually I dont really understand what you really mean.

Basically, once the lecturer has logged on to the system, they can go to any other page that i have provided.

The only reason I provide the login is basically to avoid any student that are trying to access the system and them make any room reservation purposely.
(my system is about ROOM RESERVATION)

Did you ask me for that Q?
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 13th, 2004, 08:26 AM   #8
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />Basically, once the lecturer has logged on to the system, they can go to any other page that i have provided.<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">This is what I am talking about. When you say they can go to any other page, how does that 'other' page MAKE SURE it is the lecturer, instead of someone just guessing the URL ?
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 13th, 2004, 09:50 PM   #9
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Ohhh...
Actually, i dont have that! Is it a session variable?
I didn't think of it before...!

So, that means, when the student remember the lecturer url page
(the url address after they have successfully logged on), they can just type the url, and they can access the system!
Oh my god! This is a big trouble for me...!

Can you help me Rob?
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 14th, 2004, 04:40 AM   #10
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
the check you are performing to make sure the lecturer entered the right login details.....
just make sure the same check is performed on each page.

Store the credentials in either session vars, or a cookie..... and request them on each page to compare to the database. There are of course many other ways of implementing security.... better security, but for an intranet I think this should suffice.
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 14th, 2004, 09:54 PM   #11
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Hai Rob...well actually, I have put this code on the top of my page so that any invalid user cannot get into the system without going through the login process.
Actually, I dont know the capability of this code that can detect any invalid user until I tried them just now!(entering the url)

When they type any url from the system, they will be redirect to session_ended.asp page

So...I have solve my problem!
Can we proceed with our DISPLAY USER STATUS discussion...

Code:
<%
	Response.CacheControl = "no-cache"
	Response.AddHeader "Pragma", "no-cache"
	Response.Expires = -1
	If Session("user") = "" Then
	Response.Redirect("session_ended.asp")
	end if
%>
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 15th, 2004, 05:54 AM   #12
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
Ok, now I have the REQUIRED information, I can proceed to help you.
The code you posted would need to be amended a little to make this work, so something like this should suffice.... note, I use pseudo code, and not real code... I make the assumption that you have a database and know how to connect.
Code:
<%
    Response.CacheControl = "no-cache"
    Response.AddHeader "Pragma", "no-cache"
    Response.Expires = -1
    If Session("user") = "" Then
       Response.Redirect("session_ended.asp")
    else
       ' Code to connect to the Database and update 
       ' a 'Last Active' field with the current date and time
    end if
%>
The above will obviously update your lecturers last active time in the database EVERY time he hits a protected page.

On the page where you want to show the online status, simply request the last active field..... if it falls between 10 or 20 minutes (or whatever you decide) of the current time, then it is assumed your lecturer is online.

I hope this helps you.
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 17th, 2004, 08:00 AM   #13
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />
' Code to connect to the Database and update
' a 'Last Active' field with the current date and time
<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">
I am lost at this part Rob:mad:
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 17th, 2004, 08:05 AM   #14
Highly Reputable Member
 
benbacardi's Avatar
 

Join Date: Feb 2004
Location: United Kingdom
Age: 22
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 benbacardi will become famous soon enough
here you have to connect to the database (you obviously know how to do that because you've done it before) and use an insert statement to add the current date and time into a field in the database called something like LastActive eg:

Code:
date = Now()
"INSERT INTO lecturers (LastActive) VALUES (date) WHERE lecturerid='" & lecturerid & "'"
at least, that is what i would try.... im new to this ASP stuff too!
benbacardi is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 17th, 2004, 08:11 AM   #15
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />
date = Now()
"INSERT INTO lecturers (LastActive) VALUES (date) WHERE lecturerid='" & lecturerid & "'"
<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">
Ok...
LastActive is the field in my database to store the time..right?
What about this: lecturerid='" & lecturerid & "'"?
I dont understand the bolded part! is it the unique or primary key for the lecturer?

After I have success doing that,
What about the code to display the user status (ONLINE @ OFFLINE)
I dont know how to request them from the database?
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 17th, 2004, 10:00 AM   #16
Highly Reputable Member
 
benbacardi's Avatar
 

Join Date: Feb 2004
Location: United Kingdom
Age: 22
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 benbacardi will become famous soon enough
to check who the lecturer signing in is, you must have a field in your database with the lecturers name or id? if so, then that is the record that you want to update with the time, right? so you must have some way of knowing what lecturer is signed in, then adding that value to the WHERE part of the statement so the database knows which record to update...

i have also just realised it needs to be an update statement:
Code:
rightnow = Now()
"UPDATE lecturer SET LastActive = " & rightnow & " WHERE lecturerid = '" & lecturerid & "'"
does that help? of course, you then have to execute that statement...
benbacardi is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 17th, 2004, 11:06 AM   #17
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
Monie....

You appear to be getting stuck on VERY basic things... whilst we are obviously going to continue helping you, you really should in addition, buy a book!

This will serve as an invaluable tool for 'the basics'
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 29th, 2004, 12:18 AM   #18
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
Hai benbacardi...
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!
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 & ""
	'THIS IS THE ERROR THAT I GOT: The connection cannot be used to perform this operation. It is either closed or invalid in this context
end if
%>

<html>
<head>
..
..
..
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Bookmarks

Tags
display , user , status


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Status of IE cedric813 JavaScript 1 October 21st, 2007 01:38 PM
[SOLVED] Show "Image" Depends On User "Status"? Monie Classic ASP 6 October 15th, 2007 09:22 PM
[SOLVED] User Last Visit Status Monie Classic ASP 3 October 9th, 2007 11:03 PM
Status Bar Display Brakers Your Design and Layout 0 July 22nd, 2007 10:04 AM


Search Engine Optimization by vBSEO 3.2.0 RC8