Hey Guys,
I'm working on a Login Script for my Unity Game.
Until now everything works fine, I can create new Accounts and stuff.
But now I've another problem.
Everytime I use a wrong password, the game thinks it's the correct password.
That shouldn't happen.
I guess the error is inside my PHP-Script:
//PHP Only
$Hostname = "";
$DBName = "";
$UserP = "";
$PasswordP = "";
//Email and Password
$Username = $_REQUEST["Username"];
$Password = $_REQUEST["Password"];
$conn = new mysqli($Hostname, $UserP, $PasswordP, $DBName);
if($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(!$Username || !$Password) {
echo "Login or password can't be empty.";
} else {
$SQL = "SELECT * FROM accounts WHERE Username = '" . $Username . "'";
$result_id = mysqli_query($conn, $SQL) or die ("DATABASE ERROR!");
$total = mysqli_num_rows($result_id);
if($total){
$datas = mysqli_fetch_array($result_id);
if(strcmp($Password, $datas["Password"])){
$sql2 = "SELECT Characters FROM accounts WHERE Username = '". $Username . "'";
$result_id2 = mysqli_query($conn, $sql2) or die ("DATABASE ERROR!");
while($row = mysqli_fetch_array($result_id2)){
echo $row['Characters'];
echo ":";
echo "Success";
}
} else {
echo "WrongPassword";
}
}else {
echo "NameDoesNotExist";
}
}
does anyone know how I can fix this?