Page 2 of 2
Posted: Sun Aug 10, 2003 8:17 am
by skateis2s
to test the code i put it on testing.php like this
<?
$sql = "update members set (lastmove='".time()."') where name='".$_SESSION['logged_in_user']."')";
?>
<?
$sql = "select * from members order by lastmove DESC";
$result = mysql_query($sql);
$t=1;
$timenow = time();
$intervalmins = 10;
while ($user = mysql_fetch_array($result) && $t=1) {
if (($timenow - $user['lastmove'] ) < ($intervalmins * 60)) {
echo $user['username']."<BR>";
} else {
$t=0;
}
}
?>
and I get
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xpcnbxc/public_html/csp/testing.php on line 12
go ahead and go to it here
http://is2s.net/csp/testing.php
Posted: Sun Aug 10, 2003 8:29 am
by toms100
i was only demonstrating the principle, you will need to connect to the sql server and fix the syntax errors (bound to be some)
Posted: Sun Aug 10, 2003 9:48 am
by skateis2s
Okay, sorry for the length...
Here is what I have for the registration script...
register.php
<? session_start(); ?>
<?
require "/home/xpcnbxc/public_html/csp/common/setup.inc";
if ($user && $password && $email) {
dbConnect();
$result = mysql_query ("SELECT * FROM members WHERE name = '".$user."'");
if (mysql_num_rows($result) == 0) {
$result = mysql_query ("INSERT INTO members (name, password, first_name, last_name, age, sex, state, email, aolsn, msn, icq, cs_nickname, time_playing, fav_map, fav_weapon, fav_team, part_of_team) VALUES ('".$user."', '".$password."', '".$first_name."', '".$last_name."', '".$age."', '".$sex."', '".$state."', '".$email."', '".$aolsn."', '".$msn."', '".$icq."', '".$cs_nickname."', '".$time_playing."', '".$fav_map."', '".$fav_weapon."', '".$fav_team."', '".$part_of_team."')");
if ($result) {
$subject = "Counter-strike Past Registration";
$message = "You have successfully registered at Counter-strike Past
Username: $user
Password: $password";
$logged_in_user = $user;
session_register("logged_in_user");
page_top();
page_header("Registration Complete.");
echo "<center><font size='2'>Your account information has been added to the database as, ".$logged_in_user."</font></center><br>";
echo " <a href='members.php?name=".$logged_in_user."'>Continue to the members area</a>";
page_bottom();
mail("$email", "$subject", "$message");
exit;
}
else {
page_top();
page_header("There has been a problem with inserting your data.");
setup_register();
page_bottom();
exit;
}
} else {
page_top();
page_header("The username you have chosen has already been taken.");
setup_register();
page_bottom();
} /* END ELSE FROM MYSQL NUM ROWS */
} elseif ($user || $password || $email) {
page_top();
page_header("Please fill in all the fields.");
setup_register();
page_bottom();
}
if ($logged_in_user) {
page_top();
page_header("Your logged in, you don't need to register.");
page_bottom();
exit;
}
if (!$logged_in_user) {
page_top();
page_header("Register for your free account now!");
setup_register();
page_bottom();
exit;
}
?>
If you notice I register a session with "logged_in_user", so maybe this can help with display the members online and guests online, I need to figure out how to display only the certain amount of members and guests and not ALL the USERS.... any ideas anyone. Thanks!

Posted: Mon Aug 11, 2003 4:12 am
by skateis2s
anyone have any ideas how I can display the members online and guests online???
maybe this can help. When the user logs in, it registers a session with their username as "logged_in_user". So I was thinking is it possible to show the members online by displaying how many registered sessions are online? Or anyway to show the members online and the GUEST...
Thankyou!!!!

Posted: Mon Aug 11, 2003 12:50 pm
by skateis2s
anyone???? =[

Posted: Mon Aug 11, 2003 7:38 pm
by JAM
I think that toms100 started on something very good for you to start with, and as he said, you need to add the dbconnection function etc...
Just have in mind that;
- A session closes first if the user closes ALL his browser windows. So if one browser is idling in the taskbar while he/she's at work, it's still 'sessioned'. Hence you need use the time as a counter.
To store sessions and kinda count users online, check the phpdn's membersites for the useronline-snippets. Best start.
Having a table with fields: time, name, status might be enough.
Store a member with time(), $_SESSIONї'username'],'Member'
And a Guest with time(), '$_SERVERї'REMOTE_ADDR'],'Guest' (or similiar)
based on that, you can:
їcode]
// Guestcount
select count(distinct name) from table where status = 'Guest'
// Member names
select distinct name from table where status = 'Members'ї/code]
and continue there...
To not clog up your db with to much irrelevant info, you should/can do a "delete from table..." based on the time settings you are going to use, to remove those rows that are to old (see the session issue again).
Hope I gave some more ideas...