RE: [SPAM] Re: [PHP-DB] Using sessions to gather visitor information

From: Date: Thu, 16 Sep 2004 03:23:17 +0000
Subject: RE: [SPAM] Re: [PHP-DB] Using sessions to gather visitor information
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-36216@lists.php.net to get a copy of this message
John and everyone else, thanks for all the help. Here is what I have for code. Again you help is greatly appreciated. <?php ini_set('display_errors',1); error_reporting(E_ALL & ~E_NOTICE); ini_set('register_globals',0); session_start(); // Set var $now = date('g:i'); $IP = getenv(REMOTE_ADDR); $Browser = $_SERVER['HTTP_USER_AGENT']; $Host = getHostByName($IP); // define sessions $_SESSION['ip_address'] = $IP; $_SESSION['user_agent'] = $Browser; $_SESSION['host_name'] = $Host; $_SESSION['visit_time'] = $now; // print for debug if (session_id()) { echo $_SESSION['ip_address'] . "<br />"; echo $_SESSION['user_agent'] . "<br />"; echo $_SESSION['host_name'] . "<br />"; echo $_SESSION['visit_time'] . "<br />"; } // look for db entry $IpSearch = mysql_query("SELECT ip, time FROM visitor where ip = {$_SESSION['ip_address']}"); $Results = mysql_fetch_row($IpSearch); if($Results) { // need to figure out how to check if time greater than 24 hours from now // if greater than 24 hours do: $UpdateVisit = mysql_query("UPDATE visitor SET time = '$_SESSION['visit_time']', visitcount = /* add +1 */ WHERE ip = $_SESSION['ip_address']"); } else { $InsertVisit = mysql_query("INSERT INTO visitor (ip, agent, host, time, visitcount) VALUES ($_SESSION['ip_address'], $_SESSION['user_agent'], $_SESSION['host_name'], $_SESSION['visit_time'], '1' "); ?>

« previous php.db (#36216) next »