James John – Software Engineer

PHP Class: Online Guest Count System Using PHP

Here is what we’ve got here? A PHP Online Guest Class

What Does This Do?

This class saves any guest that visits your site saving some vital details about them, refreshing the time set and counting number of guests online

How to Configure This:

Firstly, set up your database connection by editing these lines of code:

private $db = array (
        'host' => 'localhost',
        'dbuser' => 'root',
        'dbpwd' => '',
        'dbname' => 'test'
        );

 

By changing the above to your database details, the database connection has been configured. Now creating table please run this SQL Query:

CREATE TABLE IF NOT EXISTS online_users
(
id INT NOT NULL AUTO_INCREMENT,
session_id TEXT NOT NULL,
user_ip VARCHAR ( 200 ),
ua TEXT,
url_location TEXT,
online_time TEXT NOT NULL,
http_referer TEXT,
PRIMARY KEY ( id )
)Engine=MyISAM

Created successfully? Now you are good to go! 🙂

How to Use This Class

Congratulations! The class has been configured. Want more cool features?

Download code here and enjoy! 🙂

PS: Works with session_start() function, else won’t work!

James John

Software Engineer