I have a database table that has the IPs of users who visit the website. I'm trying to create an IP ban system for a page. I want the IPs that that are listed as blocked from my database table to be listed in an array of IPs that cannot access this particular page. I keep getting errors and I can't figure out how to get it to work properly. This is what i'm using so far:
PHP:
$getBlockedUsers = mysqli_query($con,"SELECT ip FROM blog_comments WHERE blocked='yes'");
$separateIps = implode(", ", mysqli_fetch_array($getBlockedUsers));
if (in_array ($_SERVER['REMOTE_ADDR'], $separateIps)) {
header("location: http://www.google.com");
exit();
}
- I'm connected to the database correctly
ip = $_SERVER[REMOTE_ADDR]?