Hello,

Any way of when a customer goes to www.domain.com/testtest

it stores the IP and then it automatically block that? or give me the opertunity to block it by htaccess?

Thank you

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 :)

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

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

How can i get the IP?

Thank you

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;
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.