Page 1 of 1

Could not register

Posted: Wed Feb 22, 2012 4:28 pm
by dido4004
Hello ,
I have another problem now whit registration.. Everything is fine. When i type the pass2 wrong it says "Your password didn't match or you did not enter a password Go back" but when i try to register it says "Could not register" can someone help me^^ im new with this i try to make browser based mmo game but :x ... ty

Re: Could not register

Posted: Wed Feb 22, 2012 5:16 pm
by dido4004
This is all in reguser.php
<?php
include 'connect.php';
?>

<?php
$player=$_POST['player'];
$password=$_POST['password'];
$pass2=$_POST['pass2'];
$player=strip_tags($player);
$email=$_POST['email'];
$email=strip_tags($email);

if ($email == "")
{
echo "You did't enter the email!<br>";
echo " <A href='register.php'>Go back<a/>";
exit;
}
if ($password==$pass2)
{

$isplayer="SELECT * from players where name='$player'";
$isplayer2=mysql_query($isplayer) or die("Could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);

if(!$_POST['password'] || !$_POST['pass2'])
{
print "You did not enter a password<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
else if($isplayer3 || strlen($player)>21 || strlen($player)<1)
{
print "There is already a player of that name or the name you specified is over 16 letters or less than 1 letter<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
else
{
$isaddress="SELECT * from players where email='$email'";
$isaddress2=mysql_query($isaddress) or die("not able to query for password");
$isaddress3=mysql_fetch_array($isaddress2);
if($isaddress3)
{
print "There is already a player with that e-mail address<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
else
{
$password=md5($password);

$SQL = "INSERT into players (name, password, email, level, exper) VALUES ('$player',$password','$email','1','0')";
mysql_query($SQL) or die("could not register");

print "Thank you for registrating!";

}
}
}

else
{
print "Your password didn't match or you did not enter a password";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
echo " <A href='login.php'>Login Page</a><br>";
?>

Re: Could not register

Posted: Wed Feb 22, 2012 6:11 pm
by Chris
Moved topic to Beginner Help and Support. This has nothing to do with game engines. Please also read this before creating another support topic:
http://indie-resource.com/forums/viewto ... =71&t=3960

Re: Could not register

Posted: Thu Feb 23, 2012 5:53 am
by Jackolantern
I will have some time to look at this tomorrow, and I don't think this is specifically your issue, but the player will never be added as-is. You can not put single-quotes around an integer value heading to the database:

Code: Select all

$SQL = "INSERT into players (name, password, email, level, exper) VALUES ('$player',$password','$email','1','0')";
mysql_query($SQL) or die("could not register"); 
That will interpret the value as a string, and you likely have the db set up to take integer values, or some other numeric type.

It should be:

Code: Select all

$SQL = "INSERT into players (name, password, email, level, exper) VALUES ('$player', '$password','$email', 1, 0)";
mysql_query($SQL) or die("could not register"); 
You were also missing a single-quote at the beginning of the $password value.

EDIT: And again, please be sure to use the correct forum sections. This was originally posted in MMO Makers after I explained what is supposed to be posted there after moving the first topic. If you have any questions about what goes into which forum section, please read the forum section descriptions on the forum index page.

Re: Could not register

Posted: Thu Feb 23, 2012 7:06 am
by dido4004
Sorry for my bad .. i read the topic with rules and i am going to be perfect :D like you ! Thank u .