MafiaHeros Posted May 15, 2012 Share Posted May 15, 2012 So i'm trying to fix that only 1 IP per account is allowed to create an account, yet players are still able to create accounts on the same ip... I have added this to register.php $checkip = mysql_query("SELECT * FROM `grpgusers` WHERE `signupip` = '".$ip.""); $ip = $_SERVER['REMOTE_ADDR']; $ip_exist = mysql_num_rows($checkip); if($ip_exist > 0) { $message = "That IP is already being used for an account on MafiaHeros."; } Anyone know what i'm doing wrong? Quote Link to comment Share on other sites More sharing options...
MafiaHeros Posted May 15, 2012 Author Share Posted May 15, 2012 Set it like this and its still not working $ip = $_SERVER['REMOTE_ADDR']; $checkip = mysql_query("SELECT * FROM `grpgusers` WHERE `signupip` = '".$ip."'"); $ip_exist = mysql_num_rows($checkip); if($ip_exist > 0) { $message = "That IP is already being used for an account on MafiaHeros."; } Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted May 15, 2012 Share Posted May 15, 2012 echo $ip Is it giving you your IP or the server IP. It is possible for the server admin to not allow remote_addr Quote Link to comment Share on other sites More sharing options...
MafiaHeros Posted May 15, 2012 Author Share Posted May 15, 2012 echo $ip Is it giving you your IP or the server IP. It is possible for the server admin to not allow remote_addr When I do that, its showing nothing just the page itself saying I registered... Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted May 15, 2012 Share Posted May 15, 2012 Well yeah you will need to place it somewhere where you can see it!! or view the source code will probably show in there. However looking at the code you have your only if( ip exists){ show this message } carry on.... There is no exit from the code so it would just continue anyway. Quote Link to comment Share on other sites More sharing options...
MafiaHeros Posted May 15, 2012 Author Share Posted May 15, 2012 (edited) Allright, it works now. Thanks for the help :) This worked: $ip = $_GET['REMOTE_ADDR']; $checkuser2 = mysql_query("SELECT * FROM `grpgusers` WHERE `ip`='$ip'"); $ip_exist2 = mysql_num_rows($checkuser2); if($ip_exist2 > 0){ $message = "<div>Your IP is already being used by another account on MafiaHeros.</div>"; } if (isset($message)) { echo Message($message); } Edited May 15, 2012 by MafiaHeros Forgot a line Quote Link to comment Share on other sites More sharing options...
MafiaHeros Posted May 15, 2012 Author Share Posted May 15, 2012 Forget my last post, now its blocking any IP that try's to register. Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted May 15, 2012 Share Posted May 15, 2012 because it's not $_GET[''REMOTE_ADDR']; but $_SERVER! $ip = $_SERVER['REMOTE_ADDR']; $checkuser2 = mysql_query("SELECT * FROM `grpgusers` WHERE `ip`='$ip'"); $ip_exist2 = mysql_num_rows($checkuser2); if($ip_exist2 > 0) { $message = "<div>Your IP is already being used by another account on MafiaHeros.</div>"; } if (isset($message)) { echo Message($message); } Quote Link to comment Share on other sites More sharing options...
Uridium Posted May 15, 2012 Share Posted May 15, 2012 confused about this bit if($ip_exist2 > 0) { $message = "<div>Your IP is already being used by another account on MafiaHeros.</div>"; } try if ($ip_exist2 == $ip) { $message = "<div>Your IP is already being used by another account on MafiaHeros.</div>"; } Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted May 15, 2012 Share Posted May 15, 2012 no illusions that should be right as it checks the number of results (rows) the query gives back. Quote Link to comment Share on other sites More sharing options...
MafiaHeros Posted May 15, 2012 Author Share Posted May 15, 2012 Woot, that worked!!! Thanks alot!!!! Quote Link to comment Share on other sites More sharing options...
Djkanna Posted May 15, 2012 Share Posted May 15, 2012 $ip = $_SERVER['REMOTE_ADDR']; $checkIP = mysql_query('SELECT `ip` FROM `grpg_users` WHERE (`ip` = "'.$ip.'")'); //Guessing the ip is stored as a string, theres functions for storing IP addresses you know. if (mysql_num_rows($checkIP) == 1) { echo 'IP exists, blah' exit; } //Continue on. mysql_query('INSERT INTO `grpg_users` ( ... ) ( ... )'); -Scratch, nevermind did not see page two. Quote Link to comment Share on other sites More sharing options...
Spudinski Posted May 15, 2012 Share Posted May 15, 2012 This is off topic... But where's Nyna's CDIR script? Anyone have it? Quote Link to comment Share on other sites More sharing options...
Djkanna Posted May 15, 2012 Share Posted May 15, 2012 (edited) This is off topic... But where's Nyna's CDIR script? Anyone have it? Google tells me it's here; http://makewebgames.io/archive/index.php/t-23395.html? (non-archive): http://makewebgames.io/showthread.php/23395-mccode-BLIP-Tables-%28Blocked-IPv4-Addresses-by-CIDR%29 Edited May 15, 2012 by Djkanna Quote Link to comment Share on other sites More sharing options...
Spudinski Posted May 15, 2012 Share Posted May 15, 2012 Google told me it's CIDR :P Google told me I can't spell... 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.