Wednesday, 8 February 2017

PHP script for getting the client IP address.




<?php
 //whether the ip is from share internet
if (!empty($_SERVER['HTTP_CLIENT_IP']))   
  {
    $ip_addr = $_SERVER['HTTP_CLIENT_IP'];
  }
//whether the ip is from a proxy
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))  
  {
    $ip_addr = $_SERVER['HTTP_X_FORWARDED_FOR'];
  }
//whether the ip is from remote address
else
  {
    $ip_addr = $_SERVER['REMOTE_ADDR'];
  }
echo $ip_addr;
?>

0 comments:

Post a Comment