Free PHP Scripts, SEO tools and tutorials - Sim.PHP


Scripts.com

Simple users online class (SimOnline)

Download: Demo:

http://www.free-midi.org

Price:

Free. If you like this script, please view my small Amazon Wish List. I will also give free tech support to those who donate :)


Description:

This very simple class enables you to track number of visitors online in an easy and accurate manner.

Main features include:
  • Automatic insertion of new user
  • Automatic database cleanup
  • Check if user is coming behind proxy server (this helps in script accuracy)
  • Display of users online
  • Error reporting
Version history:
  • v1.1 July 28, 2005
  • v1.0 December 21, 2003
Requirements:
  • PHP
  • MySQL
Installation:
  1. Execute these queries on your database:


  2. <?php
    CREATE TABLE 
    `useronline` (
      `
    idint(10NOT NULL auto_increment,
      `
    ipvarchar(15NOT NULL default '',
      `
    timestampvarchar(15NOT NULL default '',
      
    PRIMARY KEY (`id`),
      
    UNIQUE KEY `id`(`id`)
    TYPE=MyISAM COMMENT='' AUTO_INCREMENT=;
    ?>
                          

  3. Set up database connection parameters. If you don't know how, check our simple MySQL database connection tutorial.


  4. Paste this code on page where you wish your number of users online to appear (example use):


  5. <?php
     
    include_once ("usersOnline.class.php");
    $visitors_online = new usersOnline();

    if (
    count($visitors_online->error) == 0) {

        if (
    $visitors_online->count_users() == 1) {
            echo 
    "There is " $visitors_online->count_users() . " visitor online";
        }
        else {
            echo 
    "There are " $visitors_online->count_users() . " visitors online";
        }
    }
    else {
        echo 
    "<b>Users online class errors:</b><br /><ul>\r\n";
        for (
    $i 0$i count($visitors_online->error); $i ++ ) {
            echo 
    "<li>" $visitors_online->error[$i] . "</li>\r\n";
        }
        echo 
    "</ul>\r\n";

    }
    ?>
                          

  6. Thats it. Enjoy and send me your comments.
 
Sim.PHP © 2004 - Free PHP Scripts, SEO tools and tutorials | Privacy policy