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 Quote Link to comment 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. } } ?> Quote Link to comment 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? Quote Link to comment 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); Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.