dean7 Posted August 25, 2009 Share Posted August 25, 2009 Hi all, Ive got a online page so you can veiw what users are online but there is a problem with it but see why :S <? session_start(); include ("functions.php"); include ("config.php"); include ("style.css"); include ("makelogin.php"); $username=$logged['username']; $total_regged=mysql_num_rows(mysql_query("SELECT * FROM users")); $admins=mysql_num_rows(mysql_query("SELECT * FROM users WHERE level='member'")); $most=$iti->online; ?> <html><head><link rel="stylesheet" href="../../../../../../DOCUME~1/New/LOCALS~1/Temp/Rar$DI49.9672/includes/in.css" type="text/css"> <script type="text/javascript" src="../../../../../../DOCUME~1/New/LOCALS~1/Temp/Rar$DI49.9672/includes/overlib.js"></script><style type="text/css"> <!-- .style3 { color: #FFFFFF; font-weight: bold; font-size: 10px; } .style21 {font-size: 10px; color: #FFFFFF;} .style24 { font-size: 10px; font-weight: bold; } .style8 {color: #FFFFFF} .style5 {color: #FF9900} .style6 {color: #FFFF00} body { } .style1 {color: #339900} .style18 {color: #999999} .style26 { color: orange; font-weight: bold; font-size: 10px; } --> </style><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Players Online</title></head><div id=overDiv style="position:absolute; visibility:hidden; z-index:1000;"></div> </head> <body> <table width="87%" border="0" align="center" cellpadding="0" cellspacing="3"> <tr> <td height="168"><table class="thinline" width=100% border="1" cellpadding="2" cellspacing="0" bordercolor=black> <tr> <td height="28" colspan="2" bordercolor="#000000" background="includes/grad.gif" bgcolor="#000000"><div align="center"><span class="style3">Players Online </span></div></td> </tr> <tr> <td width="2%" bordercolor="#000000" bgcolor="#000000"> </td> <td bordercolor="#000000" bgcolor="#000000"><b> <font color='#3399cc'><? $timenow=time(); $select = mysql_query("SELECT * FROM users WHERE online > '$timenow' ORDER by 'level' DESC"); $num = mysql_num_rows($select); while ($i = mysql_fetch_object($select)){ if ($i->crew == "0"){ $crew="None"; }else{ $crew=$i->crew; } if ($i->last_oc > time()){ $oc="No"; }else{ $oc="Yes"; } if($i->level=="owner"){ $echo = "<font color=orange>$i->username</font>"; }elseif ($i->level=="headmod"){ $echo = "<font color=yellow>$i->username</font>"; }elseif ($i->level=="mod"){ $echo = "<b><font color='pink'>$i->username</font></b>"; }else{ $echo = "$i->username"; } echo "<a onmouseover=\"return overlib('Ready for an OC: $oc<br>Rank: $i->rank<br>Crew: $crew', STICKY, CAPTION, 'User: $i->username', CENTER);\" onmouseout=\"nd();\" href='profile.php?viewuser=$i->username' style=\"\"> $echo </a>,"; } ?></font> </b></td> </tr> <tr> <td height="27" bordercolor="#000000" bgcolor="#000000"> </td> <td height="27" bordercolor="#000000" bgcolor="#000000"><span class="style3">Total Number Of Payers Online: <font color="#ffffff"><?php echo "$num"; ?></font></span></td> </tr> <tr> <td bordercolor="#000000" bgcolor="#000000"> </td> <td bordercolor="#000000" bgcolor="#000000"> </td> </tr> <tr> <td bordercolor="#000000" bgcolor="#000000"> </td> <td bordercolor="#000000" bgcolor="#000000"><span class="style26">Orange<span class="style8">-</span></span><span class="style3">These are the owners, they run the game and code it.</span><span class="style24"><br> <font color=yellow>Yellow</font><span class="style8">- These are Head Mod they help they admins run game.</span><br> <font color=pink>Pink</font><span class="style8">- All usernames in pink are mod's they help you with basic things, any problems please ask them before anyone else.</span><br> </span><span class="style8"><span></span></span><span class="style24"><br> </span></td> </tr> </table></td> </tr> </table> <p> </p> <table align="center" width="482" height="47" border="2" bgcolor="#000000"> <tr><td width="470"> <center> <p><b><img src="Images/question mark.jpg"></b><br> <b><font color="#CCCCCC">Here, you can find out who is online, every single player who is online at this time will show up on this page. So, you can look for which staff are on. If you are looking for a certain player, I recommend you use the search player, and see if there status is "online" on there profile.</font></b> </p> </center> </table> </tr></td> </body> </html> When a user login it shows there username there but after a few minutes it goes aways while there still online, is there anyway of making there username stay there untill the do offline? Thanks Link to comment https://forums.phpfreaks.com/topic/171759-online-help/ Share on other sites More sharing options...
trq Posted August 25, 2009 Share Posted August 25, 2009 Use sessions to keep track of a users session. There are plenty of tutorials around on building a login system, one of these should get you started. Link to comment https://forums.phpfreaks.com/topic/171759-online-help/#findComment-905673 Share on other sites More sharing options...
dean7 Posted August 25, 2009 Author Share Posted August 25, 2009 Use sessions to keep track of a users session. There are plenty of tutorials around on building a login system, one of these should get you started. But wont the mean writing all my other scripts agian? Link to comment https://forums.phpfreaks.com/topic/171759-online-help/#findComment-905675 Share on other sites More sharing options...
trq Posted August 25, 2009 Share Posted August 25, 2009 Not necessarily. Link to comment https://forums.phpfreaks.com/topic/171759-online-help/#findComment-905677 Share on other sites More sharing options...
dean7 Posted August 25, 2009 Author Share Posted August 25, 2009 Not necessarily. Would it work if i just sessions in that script then? Link to comment https://forums.phpfreaks.com/topic/171759-online-help/#findComment-905680 Share on other sites More sharing options...
dean7 Posted August 25, 2009 Author Share Posted August 25, 2009 Ive put $_SESSION['username']; in the place of $logged['username']; but would it make any difference? Link to comment https://forums.phpfreaks.com/topic/171759-online-help/#findComment-905852 Share on other sites More sharing options...
lynxus Posted August 25, 2009 Share Posted August 25, 2009 basically sessions stop the need of passing variables between pages. as long as you put session_start(); at the very top of your php pages you can create session vars that pass between pages. ie: <?php session_start(); $username = "frank"; $_SESSION['username'] = $username; echo $_SESSION['username'] ; // data in $_SESSION['username'] ; will now be passed across pages. ?> Link to comment https://forums.phpfreaks.com/topic/171759-online-help/#findComment-905869 Share on other sites More sharing options...
dean7 Posted August 25, 2009 Author Share Posted August 25, 2009 If i done that on everypage would that stop they users going off the user online page when there still online? Link to comment https://forums.phpfreaks.com/topic/171759-online-help/#findComment-905902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.