Jump to content

Ip address not showing


pspfreak101

Recommended Posts

I'm working on a users online script but it doesn't show the ip address in the database only has the time stamp  I have things setup like this, the usersonline.php is required in the header.php which contains the connection and displays the users online.  How can I make it so that it adds their ip address to the database?

 

Usersonline.php

<?php
// Configuration
$timeoutseconds = 1100; // 10 minutes

$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
$ip = substr($REMOTE_ADDR, 0, strrpos($REMOTE_ADDR,"."));

$loopcap = 0;
while ($loopcap<3 && @mysql_query("insert into useronline values('$timestamp','$ip','$PHP_SELF')"))
{ // in case of collision
$timestamp = $timestamp+$ip{0}; $loopcap++;
}

@mysql_query("delete from useronline where timestamp<$timeout");

$result = @mysql_query("select distinct ip from useronline");
$user = @mysql_num_rows($result);

mysql_free_result($result);

?>

 

Link to comment
https://forums.phpfreaks.com/topic/130273-ip-address-not-showing/
Share on other sites

Your code is using at least two variables that were depreciated six years ago - $REMOTE_ADDR and $PHP_SELF. I recommend that you develop php code and debug php code on a system where error_reporting is set to E_ALL and display_errors is set to ON to get php to help you find problems like variables that don't exist.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.