Could not register

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
dido4004
Posts: 7
Joined: Tue Feb 21, 2012 9:42 pm

Could not register

Post 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
dido4004
Posts: 7
Joined: Tue Feb 21, 2012 9:42 pm

Re: Could not register

Post 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>";
?>
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: Could not register

Post 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
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Could not register

Post 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.
The indelible lord of tl;dr
dido4004
Posts: 7
Joined: Tue Feb 21, 2012 9:42 pm

Re: Could not register

Post by dido4004 »

Sorry for my bad .. i read the topic with rules and i am going to be perfect :D like you ! Thank u .
Post Reply

Return to “Beginner Help and Support”