Jump to content

I am absolutely stumped right now (IP's).


Zoofu

Recommended Posts

Im trying to track how many IP's are online.

And it's not exactly working. -.- (Not inserting).

 

 if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $CIP=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
      $CIP=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $CIP=$_SERVER['REMOTE_ADDR'];
    }

$selv300=mysql_query("SELECT * FROM `online` WHERE `ip`='$CIP'") OR die(mysql_error());
$rowv300=mysql_fetch_assoc($selv300);

if($rowv300){

}else{
            $sql400 = "INSERT INTO `online`
                    (`ip`)
                    VALUES ('".$CIP."')";
            $res400 = mysql_query($sql400) or die(mysql_error());
}

 

* - * - Edit!

 

It only works when the user is logged in for some reason, but even if they aren't online, I can still echo out their IP.

Link to comment
https://forums.phpfreaks.com/topic/189213-i-am-absolutely-stumped-right-now-ips/
Share on other sites

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.