PDA

View Full Version : User System, Help Needed



gbt91
15-04-2007, 07:24 PM
I'm working with this user system but i didnt find a way to put on the script for online users...
Help Me Plz:
Following there are the total/newest member script in case you can use it...

<?php
include('config.php');

// Query database
$count_sql = 'SELECT * FROM members';
$count_result = mysql_query($count_sql);

//gets the number
$count = mysql_num_rows($count_result);

echo $count; // displays the total members

$new = mysql_fetch_array(mysql_query("SELECT * FROM `members` ORDER BY `id` DESC LIMIT 0, 1")); // Gets the newest member
echo "Newest User: " . $new[username]; // displays the newest member
?>

CJ-real
15-04-2007, 08:04 PM
Re-describe what you are trying to do. Dont really understand :S

ScottDiamond
15-04-2007, 08:53 PM
I think he's looking for a Logged in Users script ;).

QuickScriptz
16-04-2007, 12:47 AM
Um... well basically what you would have to do is have your user system write a value to a table when a user logs in and logs out... For instance:

User Logs In: Table value `ONLINE` is set to `YES`
User Logs Out: Table value `ONLINE` is set to `NO`

And then what you would do is something similar to the above, except you tell it to count only the rows where `ONLINE` = `YES`

Make sense? Heres some pseudo-code for you...

Process Login


<?php
if($username == $database_username && $password == $database_password){
#Do other login processing stuff here.... like setting the sessions and etc
$result = mysql_query("UPDATE user_table WHERE $username = database_username SET online = 'yes'");
#What the above just did was set the online value to yes for the user who just logged in
}
?>

Count Users Online


<?php
$result = mysql_query(COUNT users WHERE online = 'yes');
$users_online = $result;
echo "There are";
echo $users_online;
echo "online";
?>
?>

phpme
16-04-2007, 03:33 AM
He wants to put on his homepage what the new users are. 1. check that the code is right + go wid Scriptz Idear.

Want to hide these adverts? Register an account for free!