Jump to content

how do i extract a local client PC private IP address with PHP


Recommended Posts

I only know how to extract public ip addresses using this:

$_SERVER['REMOTE_ADDR'];     
$_SERVER['SERVER_ADDR'];       

but i need a way to extract a pc ip address...I need this to do a condition for a service available to the local intranet members.  thank you..

This might be of some use to you:

<?php
    if ($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){
        $IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
        $proxy = $_SERVER["REMOTE_ADDR"];
        $host = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]);
    }else{
        $IP = $_SERVER["REMOTE_ADDR"];
        $host = @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
    }
?>

 

Ken

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.