How do I exclude an IP range of writing in the mysql visitors database in PHP?

I have a problem, I have to exclude the IP Range of accounting visitors mysql database, and I have this code that works well:

// time
$temps = 60*24*3600;
// send
setcookie ("ip", "Visitor", time() + $temps);
// receive
$cookie_value = "Visitor";  
setcookie("ip", $cookie_value, time()+3600, "/cookies/", "", 1, 1);  
$date=date("Y-m-d H:i:s");

$servername = "host";
$username = "user";
$password = "password";
$dbname = "database";


// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());

$sql = "INSERT INTO database ( date, ip, port, cookie)
VALUES ('$date', '$ip', '$port' , '$cookie')";

if (mysqli_query($conn, $sql)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);



How do I exclude IP Range writing ?

Any help will be truly appreciated.

Thank you.

Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.