I'm using the getenv("REMOTE_ADDR")
function to get the ip
of users who enter a certain page of my site and then I made a if
to redirect that ip
that is not equal to the variable of ip
allowed. But when I play in the hosting it does not catch the ip
of who is accessing but another ip
.
Does anyone know why or do you know another method?
<?php
$pegar_ip = $_SERVER["REMOTE_ADDR"];
$ip_permitido = "ip_permitido";
if ($pegar_ip == $ip_permitido)
{
echo 'Ip Permitido!';
}
else
{
header("Location: url");
}
?>