primefalcon Posted April 24, 2007 Share Posted April 24, 2007 I'm trying to set it up so I can block certain ip addresses from submitting on a form I have:this is the code <?php/*List of banned ip addresses*/$banned = array("##.##.##.##","##.##.##.##","##.##.##.##");/*current user ip lookup/*$userip = $_SERVER['REMOTE_ADDR'];/*comparing users ip to banned list*/if($userip == $banned[""]){ echo "<br/><br/><center>You have been banned from submitting entries</center>"; exit(); }?> I cant seem to get this thing working right Link to comment Share on other sites More sharing options...
justsomeguy Posted April 24, 2007 Share Posted April 24, 2007 The value $banned[""] is a specific value, it does not search through the array. If you want to check if the IP is in the array, use this: if(in_array($userip, $banned)){ Link to comment Share on other sites More sharing options...
justsomeguy Posted April 24, 2007 Share Posted April 24, 2007 Also, one of the ending comments is incorrect, you are commenting out the $userip = line. Link to comment Share on other sites More sharing options...
primefalcon Posted April 24, 2007 Author Share Posted April 24, 2007 yup that does it thx again so much for your help. I really appreciate it Link to comment Share on other sites More sharing options...
primefalcon Posted April 24, 2007 Author Share Posted April 24, 2007 that comment thing Isn't in my script I'm using I only threw in for visual reference to make it easier here Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.