You can simply use: <?php echo $_SERVER['REMOTE_ADDR']; ?> Or you can use detailed script below: <?php //Mainly, $_SERVER['REMOTE_ADDR'] contains IP address of client who viewing the page function get_client_ip($single = 2) { $ipaddress = array(); if( $single == 2){ if (isset($_SERVER['HTTP_CLIENT_IP'])) $ipaddress[] = $_SERVER['HTTP_CLIENT_IP']; if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ipaddress[] = $_SERVER['HTTP_X_FORWARDED_FOR']; if(isset($_SERVER['HTTP_X_FORWARDED'])) $ipaddress[] = $_SERVER['HTTP_X_FORWARDED']; if(isset($_SERVER['HTTP_FORWARDED_FOR'])) $ipaddress[] = $_SERVER['HTTP_FORWARDED_FOR']; if(isset($_SERVER['HTTP_FORWARDED'])) $ipaddress[] = $_SERVER['HTTP_FORWARDED']; if(isset($_SERVER['REMOTE_ADDR'])) $ipaddress[] = $_SERVER['REMOTE_ADDR']; if(count($ipaddress) == 0) $ipaddress[] = 'UNKNOWN'; $ips = implode(", ", array_unique($ipaddress)); } if( $single == 1){ $ips = $_SERVER['REMOTE_ADDR']; } return $ips; } ?>