UCP isn't reading passwords from database... (+rep)
#1

Okay so i hash my password in my script with WP_Hash and it works in the game but i have been creating a UCP and i ahve everything setup to choose from the database and read the password and it doesnt take it, it always says it wrong. i ahve no idea what i have done. everything looks fine to me...

The .php code for the login poart
Код:
	$query = "SELECT * FROM `Users` WHERE `Name`= '".$_SESSION['Character']."' AND `Password`= '".$_SESSION['Key']."'";
	$result = mysql_query($query);
	if(mysql_num_rows($result) == 0)
	{	
		$wa = mysql_num_rows($result);
		unset ($_SESSION['Key'],$_SESSION['Character']);
		echo 'Username and password do not match!<br>Make sure that you wrote your character'."'".'s IG name with a "_".<meta HTTP-EQUIV="REFRESH" content="3; url=index.php">';
	}
I really am stumped and cannot move on with editing my ucp and it is really holding me back. Thank you, (Post below if you need to see anyother part of the code from the .pwn or .php.
Reply
#2

Please, please, stop using the "mysql" extension. Especially in new projects. The extension has been deprecated and has been completely removed in PHP7. Once hosts start to migrate to PHP7 this code will just cease to work. Use mysqli or PDO instead. It's seriously not that hard.

Also I have no idea why you are even storing the password in a session variable since it is presumably only needed once. But you will need to show where and how you retrieve it, regardless.
Reply
#3

I have everything in the Script and on the UCP in mysql

Код:
if(!isset($_SESSION['Character'])&&!isset($_SESSION['Key'])&&!isset($_POST['Character']) && !isset($_POST['Key']))//login page part
{
	echo '<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
		<tr>
		<form name="form1" method="post" action="index.php">
		<td>
		<table width="100%" border="0" cellpadding="3" cellspacing="1">
		<tr>
		<td colspan="3"><strong><span style="color:white">Character Login</span></strong></td>
		</tr>
		<tr>
		<td width="78"><span style="color:white">Username:</span></td>
		<td width="294"><input name="Character" type="text" id="Character"></td>
		</tr>
		<tr>
		<td><span style="color:white">Password:</span></td>
		<td><input name="Key" type="password" id="Key"><input type="submit" name="Submit" value="Login"></td>
		</tr>
		</table>
		</td>
		</form>
		</tr>
		</table>';
}
Код:
if(!session_start())
{
	echo "Can't start session!";
	exit;
}
if(isset($_POST['Character']))
{
	$_SESSION['Character'] = $_POST['Character'];
	unset($_POST['Character']);
}
if(isset($_POST['Key']))
{
	$_SESSION['Key'] = $_POST['Key'];
	unset($_POST['Key']);
}
So i dont need the Sessions for Character and Key?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)