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 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);
}
?>