jck Posted July 14, 2007 Share Posted July 14, 2007 my login system works like this is there anyway i can make a who is online script <? require_once("conn.php"); if(isset($_POST[s1])) { $q1 = "select * from dd_users where username = '$_POST[u1]' and password = '$_POST[p1]' "; $r1 = mysql_query($q1) or die(mysql_error()); if(mysql_num_rows($r1) == '1') { $_SESSION[username] = $_POST[u1]; header("location:index.php"); exit(); } } //get the templates require_once("templates/MainHeader.php"); require_once("templates/MainLogin.php"); require_once("templates/MainFooter.php"); ?> Quote Link to comment Share on other sites More sharing options...
trq Posted July 14, 2007 Share Posted July 14, 2007 All you need do is, as your users login add them to a table logged in along with a timestamp of when they logged in. This timestamp will then need to be updated on each request made by the user. Then, simply run a cron every 5 mins or so that deletes entries older than five minutes. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 14, 2007 Share Posted July 14, 2007 If you dont have the ability to run a cron, then just store the last active time as was suggested, and then for your users online page, select only those users who were last active less than 5/10 minutes ago. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.