Overview
This PHP function will allow you to get the current users IP address.
PHP Code:
<?php function get_ipaddress(){ //GET IP ADDRESS if ($_SERVER['HTTP_CLIENT_IP']){ $ipaddress = $_SERVER['HTTP_CLIENT_IP']; }elseif($_SERVER['HTTP_X_FORWARDED_FOR']){ $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; }elseif($_SERVER['HTTP_X_FORWARDED']){ $ipaddress = $_SERVER['HTTP_X_FORWARDED']; }else if($_SERVER['HTTP_FORWARDED_FOR']){ $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; }else if($_SERVER['HTTP_FORWARDED']){ $ipaddress = $_SERVER['HTTP_FORWARDED']; }else if($_SERVER['REMOTE_ADDR']){ $ipaddress = $_SERVER['REMOTE_ADDR']; }else{ $ipaddress = ''; } return $ipaddress; } //CALL get_ipaddress FUNCTION echo get_ipaddress(); ?>