ghurty Posted November 18, 2007 Share Posted November 18, 2007 Hi I have a php script that I only what to be executed if the visitor is from a paticular ip range (for example 192.168.5.*), what lines would I add to accomplish this? Thanks Link to comment https://forums.phpfreaks.com/topic/77867-how-to-get-a-script-to-run-only-if-viewer-is-from-a-particular-ip-address/ Share on other sites More sharing options...
trq Posted November 18, 2007 Share Posted November 18, 2007 <?php if (!substr($_SERVER['REMOTE_ADDR'],0,9) == '192.168.5.')) { die(); } else { // rest of script. } ?> Be aware though that relying on an ip is a very unreliable way of tracking a user. Link to comment https://forums.phpfreaks.com/topic/77867-how-to-get-a-script-to-run-only-if-viewer-is-from-a-particular-ip-address/#findComment-394123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.