Jump to content

Questions :D


ScottCFR

Recommended Posts

Hello,

 

This is my first time on these forums, I don't know if I am posting in the correct category. But anyways, I am trying to make a page on my site where I want to restrict to certain IPs. I don't have any code started, that's because I don't know what to do in this situation.

 

Thanks,

Scott W.

Link to comment
https://forums.phpfreaks.com/topic/205914-questions-d/
Share on other sites

Forcing authentication is a better option than allowing certain IP addresses. IP addresses change, can be spoofed, etc.[/Quote]

 

That is true, But here is the solution for what you asked..

 

$ip = $_SERVER['REMOTE_ADDR'];
if($ip != "xxx.xxx.xxx.xxx" || $ip != "xxx.xxx.xxx.xxx" || $ip != "xxx.xxx.xxx.xxx")
{
echo "Access Denied!";
} else {
echo "Page content";
}

Link to comment
https://forums.phpfreaks.com/topic/205914-questions-d/#findComment-1077513
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.