i need a code to ipban people from my site, does anyone know how?
Printable View
i need a code to ipban people from my site, does anyone know how?
$ip = $_SERVER['REMOTE_ADDR'];
And then depending on how you render your page, if the IP matches an IP in your banlist, deny them access.
look, can you explain the code, how do i use it and...?
I coulda swore this was in the PHP section..
The function I gave you is PHP. Google "PHP Tutorials" if you want an into into it.
You can do it with other server-side scripting language as well. If you plan to use HTML or JavaScript to stop someone from a certain IP from visiting your site -- you cannot.
oh, thank you.
found a code...
Code:<?php
$ban_ip = 'iphere';
$visitor_ip = $_SERVER['REMOTE_ADDR'];
if($visitor_ip == $ban_ip)
{
die("You are banned from this site!");
}
$visitor_ip = $_SERVER['REMOTE_ADDR'];
$ip_list = explode(",", $ban_ip);
foreach($ip_list as $ip)
{
if($visitor_ip == $ip)
{
die("You are banned from this site!");
}
}
?>
sorry for double post...