anybody99 Posted March 11, 2007 Share Posted March 11, 2007 hey, i look for a code [maybe some 1 knows already] to automaticley block an IP address that it is located in the DB, to prevent users from accessing my site twice. if some1 know already when i can get that code that i will be glad, also i have found that code: $ip = $_SERVER['REMOTE_ADDR']; if($ip == "123.123.123.123" || $ip == "213.213.213.213") { // YOUR BANNED } else { // YOUR NOT BANNED } but it is not automatic and not from DB. -Rob Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/ Share on other sites More sharing options...
trq Posted March 11, 2007 Share Posted March 11, 2007 A simple example. <?php // connect to db. $sql = "SELECT ip FROM banned WHERE ip = '{$_SERVER['REMOTE_ADDR']}'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { // user is banned. } else { // user is ok. } } ?> Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204787 Share on other sites More sharing options...
anybody99 Posted March 11, 2007 Author Share Posted March 11, 2007 ok, but now i need to record each IP to the DB, how i do that? Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204789 Share on other sites More sharing options...
papaface Posted March 11, 2007 Share Posted March 11, 2007 Simple: $ip = $_SERVER['REMOTE_ADDR']; $sql = "insert into banned (ip) values ('{$ip}')"; mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204792 Share on other sites More sharing options...
trq Posted March 11, 2007 Share Posted March 11, 2007 Write an insert query that does so. A big part of learning to program is to learn how to take examples and turn them into usable code. Im not going to write the thing for you, you'll need to think for yourself. Sorry. Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204793 Share on other sites More sharing options...
anybody99 Posted March 11, 2007 Author Share Posted March 11, 2007 well i dont want or need to learn the language because i am not using it. Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204796 Share on other sites More sharing options...
smc Posted March 11, 2007 Share Posted March 11, 2007 well i dont want or need to learn the language because i am not using it. Well then I recommend you look in the freelance section and pay someone to design for you. This is all about helping coders learn and develop their website, not a charity for those that don't want to bother. Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204800 Share on other sites More sharing options...
anybody99 Posted March 11, 2007 Author Share Posted March 11, 2007 i do want to bother, i already learnd CSS and html all by myself but php is a lot of stuff to learn dude Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204802 Share on other sites More sharing options...
darkcarnival Posted March 11, 2007 Share Posted March 11, 2007 php is actually one of the easier languages on the net to learn, it has much more information and is easy to grasp after a while. if your not willing to learn,you may want to use a pre-made script, check out hotscripts.com for something like that. Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204812 Share on other sites More sharing options...
trq Posted March 11, 2007 Share Posted March 11, 2007 well i dont want or need to learn the language because i am not using it. Well what exactly are you doing on a PHP Help forum then? Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204823 Share on other sites More sharing options...
legohead6 Posted March 11, 2007 Share Posted March 11, 2007 php is easy to learn but hard to master. Lots of it is common sence. and if you already to coding in other languages it will make it that much easier. but of you dont want to learn then people arent just going to make your site for you. Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204860 Share on other sites More sharing options...
anybody99 Posted March 11, 2007 Author Share Posted March 11, 2007 im exhusted, i have tried a lot of things, thanks anyway for those who helped, -Rob Link to comment https://forums.phpfreaks.com/topic/42219-automatic-ip-blocking-from-db/#findComment-204880 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.