I have problems with my register/login system
I watched Howell's tutorial on Youtube about making MMORPG
i did everything like he did,and it looks like everything works just fine
but I realised that i have problem with register/login system.
Here is explanation of the problems
Register works just fine,but when i try to login,for some passwords it just says that i typed wrong username of password (that's impossible,i tried many,many times)
I noticed that some passwords works fine,but with some of them i just can't login
so i tried different combinations:
Username | password
player1 | pass1 -works
player2 | pass2 -doesn't work
player3 | pass3 -works
player4 | pass4 -doesn't work
player5 | pass5 -doesn't work
player6 | pass6 -doesn't work
player7 | pass7 -works
I also notied that if i delete those players from database and register again with different combination,this happens
pass7 works for all these nicks,and pass2 doesn't work with any of these nicks,so it depends on passwords is it going to work or not
I'm really confused,don't understand why is this happening
I need your help,here is the code of "authenticate.php",that decide,whether username and password match with those in database
Code: Select all
<?php
include_once 'connect.php';
session_start();
if (isset ($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);
$query = "Select name,password from players where name='$player' and '$password'";
$result = mysql_query ($query) or die ("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;
echo "<big>Logged in successfully<br>";
echo "<A href='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password.<A href='login.php'>Try again</a></big>";
}
}
?>