How to gain access to a visitor's IP address in PHP
PHP's HTTP_X_FORWARDED_FOR and REMOTE_ADDR server variables store the IP Addresses of a visitor's connection and any proxy server that their connection was forwarded through.
To use these details in your code, write a script similar to this:
<?php
$addressForwarded = $_SERVER['HTTP_X_FORWARDED_FOR'];
$addressRemote = $_SERVER['REMOTE_ADDR'];
echo "Connection forwarded for: {$addressForwarded} " .
"and originated from {$addressRemote}.";
?>