Jump to content
MakeWebGames

Recommended Posts

Posted

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?

Posted

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.";
 }

Posted
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...

Posted

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.

Posted (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 by MafiaHeros
Forgot a line
Posted

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);
}
Posted

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>";

}

Posted
$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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...