» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-14-2006, 01:39 PM
segio segio is offline
Junior Member
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
segio is on a distinguished road
Default how can i create a "users logged in now" script

Hi
I have a startup website, and i use php with a mysql backend to store information.

my question is, how can i create a "users logged in now" script? i want to have the "users logged in now" part of the site dynamic, instead of having to purge the user login cache (login information is stored as a 1 or 0 in user database)?

right now, when a user logs in, the login field on his database entry becomes 1, but if he doesnt log out by clicking "logout" (i.e. he closes the browser window) he remains "logged in." i only want to show people who are logged in (and clicking) at the time the page is loaded.
Thanks in advance -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-14-2006, 01:42 PM
onlineking onlineking is offline
OSP Starters
 
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
onlineking is on a distinguished road
Default

Try this code:

<?php

// ... init classes and whatnot...

if($user->logged != true)
{
$display->tpl('login_you_idiot');
}

// ... once the idiot logs in..

$db->query("UPDATE `status` SET `logged` = '1' WHERE `id = '{$user->id}'");

// where did $user->id come from? once the user logged in set the new values

// ...

?>

What you are asking for requires a full working member system thin -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  #3  
Old 08-14-2006, 01:43 PM
lazer lazer is offline
OSP Starters
 
Join Date: Mar 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
lazer is on a distinguished road
Default

I would set a date/time combination in my DB rather than adding a 'logged in boolean' like webviz suggested.

If the user would log on a boolean login system but would not log out properly, the user could be 'active' forever, unless the system would actively scan the userlist, which is a waste of resources.

When setting a date, you could use a simple query like;

SELECT users FROM table WHERE logindate > 01-01-2006 AND logintime > 10:00:00 sprt by users desc;

And when you have stored a date/time combination in your db you can also add a welcome message like;

Welcome user, your last login was on xx:xx, xx-xx-xxxx!

regards -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use CREATE PROCEDURE? silvair MySQL Forums 1 09-06-2006 07:44 AM
Can FTP sessions be carried to another script? kipper PHP Programming and Tips 1 08-12-2006 10:52 AM


All times are GMT. The time now is 11:46 AM.