2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by hashinclude
0

you can use $_SERVER which returns the ip address of the person browsing the page

something like this

$ip = $_SERVER['REMOTE_ADDR'];

if ($ip == '127.0.0.1')
{
exit('blocked');
}

just an example :)

0

Thanks for the example, its a start :)

How can i put mulitple addresses? Also where it says exit 'blocked' can i put a link to say banned or not display anything?

Also how can i store the IP to a database?

Thank you

0

With that the code, i get 127 ip but mine is 87?

How can i get the IP?

Thank you

0

With that the code, i get 127 ip but mine is 87?

How can i get the IP?

Thank you

if you're getting the ip as 127.0.0.1 then you are browsing the page from the web server itself ..

if you want to check against multiple addresses , try getting a list of addresses from a database, something along these lines:

$result = mysql_query("SELECT ip_address FROM ip_address_blacklist");
while($row = mysql_fetch_array($result))
{

if ($_SERVER['REMOTE_ADDR'] == $row['ip_address'])
{
echo 'this ip address is blocked';
break;
}
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.