CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Need PHP Code for Users Online

Print topic Send  topic

Author Message
sgadson
Posted: 11/30/2003, 8:49 PM

Hello,

I am in search of exact PHP code for determining the number of users online on my community web site.

I have a table name profiles with a field name is_online. What I would like to do is when a user loggs in, the is_online field is updated to "yes". And when a user signs out, I would like to update the is_online field of the profiles table to "no". I do not know how to add custom code to the Login event to update the profiles table.

Can anyboy reply with the PHP code that I should use to accomplish what I have described above. I am using the latest version of CodeCharge Studio, PHP with templates, and MySQL database. Please let me know where to place the custom code that you send me.

Note: I know that there are other discussion threads on this subject, but they did not provide me with enough information. I need to know exactly where to place the code.

Thanks in advance for your help.
S Gadson
feha
Posted: 12/01/2003, 8:05 AM

Check This Tutorial it may help you ...
http://www.rexdesign.com/ccs/kb.php?category_id=55&lang...d=7&event_id=74
(You have to register as a member ...)

regards
feha
[www.vision.to]
sgadson
Posted: 12/02/2003, 5:49 PM

Thanks for the response. But I am still in need of some assistance. Just incase my orignial message does not appear with this response, here is what I am trying to accomplish.

*************Previous Post**********************
Hello,

I am in search of exact PHP code for determining the number of users online on my community web site.

I have a table name profiles with a field name is_online. What I would like to do is when a user loggs in, the is_online field is updated to "yes". And when a user signs out, I would like to update the is_online field of the profiles table to "no". I do not know how to add custom code to the Login event to update the profiles table.

Can anyboy reply with the PHP code that I should use to accomplish what I have described above. I am using the latest version of CodeCharge Studio, PHP with templates, and MySQL database. Please let me know where to place the custom code that you send me.

Note: I know that there are other discussion threads on this subject, but they did not provide me with enough information. I need to know exactly where to place the code.



*******************************Help Needed*************************
Now here is the code that I have so far. Some of the code is working as it should as some of it isn't. I am looking for help in finding the mistakes. Here are the parts that are not working:

1. The Visits counter is not working in the Login function. The field constantly holds the value 1, no matter how many times you log in.

2. In the log out area, I want the is_online field of the Profiles_tbl to update to 0. This is not happening.


************current code**************************

//CCLoginUser @0-A6EE8EB2
function CCLoginUser($login, $password)
{
$db = new clsDBEA();
$SQL = "SELECT ID, Group_ID FROM Profile_tbl WHERE Screen_Name=" . $db->ToSQL($login, ccsText) . " AND Password=" . $db->ToSQL($password, ccsText);
$db->query($SQL);
$Result = $db->next_record();
if($Result)
{
CCSetSession("UserID", $db->f("ID"));
CCSetSession("UserLogin", $login);
CCSetSession("UserPassword", $password);
CCSetSession("GroupID", $db->f("Group_ID"));
CCSetSession("MemberVisits",$db->f("Visits")+1);
CCSetSession("MemberLastLogin",$db->f("LastLogin"));
CCSetSession("MemberOnline",$db->f("is_online")?$db->f("is_online"):1);
}
$db->close();
// here it is // UPDATE Visits and LastLogin //
$SQL="UPDATE Bi_Profile_tbl SET is_online=".CCGetSession("MemberOnline").",Visits=".CCGetSession("MemberVisits").",LastLogin='".date("Y-m-d H:i:s")."' WHERE ID=".CCGetSession("UserID");
$db->query($SQL);
$db->close();
return $Result;
}
//End CCLoginUser

//CCLogoutUser @0-AD68F376
function CCLogoutUser()
{
CCSetSession("MemberOnline",$db->f("is_online")?$db->f("is_online"):0);
// here it is // UPDATE is online status to offline//
$SQL="UPDATE Profile_tbl SET is_online=".CCGetSession("MemberOnline")." WHERE ID=".CCGetSession("UserID");
$db->query($SQL);
$db->close();
CCSetSession("UserID", "");
CCSetSession("UserLogin", "");
CCSetSession("UserPassword", "");
CCSetSession("GroupID", "");
}
//End CCLogoutUser

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.