Jump to content


Photo

How would you suggest.....


  • Please log in to reply
9 replies to this topic

#1 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 19 July 2006 - 07:58 PM

How would you suggest that i record whether or not a member of my site is logged in?

I was thinking, that i add a column to my table that holds the users info, called onlinestatus or something. When they log in, i use a query to update it to online..... but how would i update it to offline if the member exits the browser?

Or is their a special method for doing this?

Thanks in advance for any help

-Tandem

#2 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 19 July 2006 - 08:03 PM

Sessions. Read the PHP manual for more information, and come back with any questions.
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:
http://php.net/manual/en/index.php

#3 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 19 July 2006 - 08:29 PM

^ Dude, that's not what he's talking about.

You want to show members online, right? There's a PHP tutorial on PHP freaks that tells you how to do it. Basically, you set a cookie with the current time and every time a page is loaded you see if the cookie time is more than 5 minutes different from the current time. If it is, update the database with the new time they were on and update the cookie.

When you go to select from the database, just select the member whose "timeonline" is within in the last 5 minutes.

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!


#4 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 19 July 2006 - 08:37 PM

look at this topic:

http://www.phpfreaks...c,100488.0.html

already discussed this a fair bit (with pixy).

#5 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 19 July 2006 - 09:18 PM

Ok, thankyou.

#6 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 19 July 2006 - 09:43 PM

I'm still having some trouble understanding this.
Lets say for examples sake, my table with the users information in it, that i want the online status to be stored in, hasn't got any fields relating to the whole online status issue in it.

Could someone tell me what fields i would need to add, what code i would need to put and where, and explain to me what the important pieces of code do and how they operate?

Sorry if thats kind of demanding, but i'm really quite stuck and would like to know what to do rather than aimless trial and error ;).

I would be really grateful for any further help, and thanks in advance!

#7 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 July 2006 - 09:52 PM

This can be done in 4 ways,
Sessions, cookies, databasing, or putting the info in some sort of  file, flat file, or excel sheet.
All you are needing to do is store a time period/
wait you are wanting instant record, to show when they are online, and when they are not.

Here
Create a new column in your table, label it only.
then when they log on, have it automatically update that, to show online, wherever you want to display the online status pull it from the .
like
SELECT * FROM tablename WHERE online = 'yes';
then run that through all your queries or what not, at that time it will show yes, or no.  You can have a function or something
if ($online == "yes") {
}
whatever int hat if, if you wanted a picture to light up when there online you would put
<img src=""
whatever to have it appear when they are online, or you could put
echo "Online"
or whatever you wanted to do, then when they log off have it kill the script and say they are offline, have it change to no in the database, you might have some problems if people don't log off, so if you want another approach You can have it log them in when they log on, well actually, I don't know, I am stumped on how to set that up, if I think of anything further I Will let you know.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#8 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 July 2006 - 09:59 PM

I checked and these 2 things seem to be your only 2 viable solutions.
For the table add 1 column, name it
login- datetime
whatever
record the exact time and date they log in, then where you are displaying the data, pull the entire out of the database to display people that are online, something like assuming your table is named userinfo your date and time is labeled datetime
$select = "SELECT datetime FROM userinfo SORT BY datetype LIMIT 10;";
$query = mysql_query($select);
then whatever to display the results, you could probably come up with some php calculations to only pull out show the ones for the last 20 minutes, so you know that they all were atleast logged in within the past 10-20 minutes, the only other options would be flash, perl, c+, or something more advanced, or setting up a chat like system using perl, or cgi-based programming, and with that, using it on your site, or look for external programs for your server that can detect when people are connected to your site.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#9 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 19 July 2006 - 10:11 PM

Ok so i'm going to include at the top of each page, a script that records the time the page was loaded. Then i would class people who had loaded a page within a certain time range as Online and everyone else offline.

Thankyou everyone for the help :)

#10 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 July 2006 - 10:11 PM

your welcome

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users