Session variables - Users online

From: Date: Fri, 07 Sep 2001 08:36:55 +0000
Subject: Session variables - Users online
Groups: php.general 
Request: Send a blank email to php-general+get-66360@lists.php.net to get a copy of this message
put this code in the home web page <?php $timeoutsecs = 900; $timestamp = time(); $caduc = $timestamp+$timeoutsecs; $conexion = @mysql_connect("localhost", "user", "password") or die ("No db CONEXION"); mysql_select_db ("yourdb", $conexion); mysql_query("INSERT INTO uonline SET " . "caduc='$caduc'," . "ip='$REMOTE_ADDR'," . "file='$PHP_SELF'"); mysql_query("DELETE FROM uonline WHERE caduc<'$timestamp'"); $result = mysql_query("SELECT DISTINCT ip FROM uonline"); $conn = mysql_num_rows($result); $dbdecnx = mysql_close ($conexion); if ($conn==1) { echo"<span class=\"textPequ\">$conn user online</span>"; } else { echo"<span class=\"textPequ\">$conn users online</span>"; } ?> and create this table in you db to hold the necesary values # # Table structure for table 'uonline' # CREATE TABLE uonline ( caduc int(15) NOT NULL default '0', ip varchar(40) NOT NULL default '', file varchar(100) NOT NULL default '', PRIMARY KEY (caduc), KEY ip (ip), KEY file (file) ) TYPE=MyISAM; this is working good in my site Aniceto Lopez http://www.lamundial.net download and spread our music

« previous php.general (#66360) next »