$valid_ips = ['192.168.0.1', '127.0.0.1', '192.168.0.2']; $user_ip = $_SERVER['REMOTE_ADDR']; if (in_array($user_ip, $valid_ips)) { // perform validation } else { // deny access }
$log_message = 'User accessed page from IP: '.$_SERVER['REMOTE_ADDR']; file_put_contents('access.log', $log_message, FILE_APPEND);The package library for the PHP function GetRemoteIP is the PHP core library. It is available in all versions of PHP.