Page 1 of 3

Yet another error

Posted: Fri Aug 07, 2009 12:56 am
by Rob
Well, I log in to the mmorpg yet it always says its the wrong username or password even if its right.

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

Re: Yet another error

Posted: Fri Aug 07, 2009 1:24 am
by Torniquet
my guess would be the following line..


$query = "select name,password from players where name='$player' and 'password'";



try

$query = "select name,password from players where name='$player' and password='$password'";

Re: Yet another error

Posted: Fri Aug 07, 2009 2:54 am
by Noctrine
You guys' queries always look so nasty ><

Re: Yet another error

Posted: Fri Aug 07, 2009 11:31 am
by Rob
Its still not logging in.

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='$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>";
	}
}
?>

Re: Yet another error

Posted: Fri Aug 07, 2009 11:45 am
by hallsofvallhalla
is it actually saying "wrong username or password"?

check you database and make sure all feilds in the players table are exactly the same, no capitals, ect... This has been 95% of the erros we have seen so far from users. take a screen shot of your players table in your database.

Re: Yet another error

Posted: Fri Aug 07, 2009 11:55 am
by Rob
Image

as you can see, i even put player one's email the same as the tutorial, but I dont use him to login I use the others

http://img16.imageshack.us/img16/5238/l ... tmmorp.png

Re: Yet another error

Posted: Fri Aug 07, 2009 12:03 pm
by hallsofvallhalla
what happens if you just put player1 as username and nothing for the password?

also post your register.php here

Re: Yet another error

Posted: Fri Aug 07, 2009 12:04 pm
by Rob

Code: Select all

<?php
include 'connect.php';

?>

<form method="post" action="reguser.php">
Type Username Here: <input type="text" name="player" size="21"><br>
Type Password Here: <input type="text" name="password" size="15"><br>
ReType Password Here: <input type="text" name="pass2" size="15"><br>
Type Email Address: <input type="text" name="email" size="55"><br>

<input type="submit" value="Submit">

Re: Yet another error

Posted: Fri Aug 07, 2009 12:07 pm
by hallsofvallhalla
very strange indeed, what happens when you try to use player1 login?

Re: Yet another error

Posted: Fri Aug 07, 2009 12:08 pm
by Rob
the same, Wrong username and password...

do you want my ip so you can try it out?