Get a users IP Address

Grab the users IP address, handy to add to login scripts if you want to tighten security… Or to just keep track… $Users_IP_address = $_SERVER["REMOTE_ADDR"]; If the user is operating...

Grab the users IP address, handy to add to login scripts if you want to tighten security… Or to just keep track…

$Users_IP_address = $_SERVER["REMOTE_ADDR"];

If the user is operating via a proxy server, the above code may not work. In this case use this simple function:

<?php

 function VisitorIP(){
    if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
        $TheIp=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else {
        $TheIp=$_SERVER['REMOTE_ADDR'];
    }

    return trim($TheIp);
    }

?>

Snippet from http://wiki.jumba.com.au/wiki/PHP_Get_user_IP_Address

Related posts:

  1. Users IP Address
  2. $_SERVER['DOCUMENT_ROOT']

This post has had 131 views