Bladephp: Now with 7+ codeigniter, php, and laravel project 7+ php project From $18/Year From Rs. 1000/Year

How to Block User From Visiting Website Using PHP

by
Category:php
php
How to Block User From Visiting Website Using PHP

There are many reasons you may need to block an IP address from visiting your website. Using PHP, you can easily find your site visitors' website addresses and based on these addresses to redirect them to specific places on your site. You may also like How to Get User Location Using IP Address In PHP and How to get Browser name, useragent, version, platform and pattern in PHP.

PHP Code

<?php
    $user_ip=$_SERVER['REMOTE_ADDR'];
    $get_result = mysqli_query($con, "select * from blocked_user where ip = '".$user_ip."' ");
    if(mysql_num_rows($get_result)>0)
    {
        echo "<h1>Your Are Blocked From Visiting This Website</h1>";
    }
?>

0 Comments


Html code work in comment box


Related Post