Help with whirlpool connecting to php from SAMP -
kevin1990 - 05.03.2015
Ok, Dont know hwy my previous thread got closed as this does have to do with SAMP.
and I have seen other UserCP on here before
Anyway..
So I used a print_r on my hash to make sure it was hashing the same as the Key in teh SAMP Db and it is.. YEt it still will not connect me and give me the error in my query.
I know I am connect to the DB because I used that echo and it does output correctly
Код:
<?php
$con = mysqli_connect('###', '###', '###', '###');
session_start();
if(mysqli_connect_errno()) {
echo 'Failed to Connect to MySQL' . mysqli_connect_errno();
} else {
echo 'Connected just fine!';
echo '<br>';
}
if(isset($_POST['submit'])) {
//Variables
$user = $_POST['username'];
$zone = $_POST['password'];
$pass = strtoupper(hash("whirlpool", $zone));
//Just quickly printing to check its the same as the DB ** It is.
print_r($pass);
$query = mysqli_query($con, "SELECT * FROM accounts WHERE Username = '$user' AND Key = '$pass'") or die("Can not query the DB");
$count = mysqli_num_rows($query);
if($count == 1) {
$_SESSION['username'] = $user;
header('Location: members.php');
} else {
echo 'Username and Password do not match! Try Again';
session_destroy();
}
}
?>
This is the password the PHP prints
Код:
344907E89B981CAF221D05F597EB57A6AF408F15F4DD7895BBD1B96A2938EC24A7DCF23ACB94ECE0B6D7B0640358BC56BDB448194B9305311AFF038A834A079F
This is the password the Db for SA:MP has saved
Код:
344907E89B981CAF221D05F597EB57A6AF408F15F4DD7895BBD1B96A2938EC24A7DCF23ACB94ECE0B6D7B0640358BC56BDB448194B9305311AFF038A834A079F
As you can see, They are identical but it still gives me the "Cant Query DB error"
If I remove "AND Key = '$pass'" from my query line though and just check to see if the Username matches.
it all works and loads all of the players info from the SA:MP DB
I need it to work with the password too though.
AW: Help with whirlpool connecting to php -
Kaliber - 05.03.2015
Dude, write the query like this:
Код:
"SELECT * FROM `accounts` WHERE `Username` = '$user' AND `Key` = '$pass'"
Greekz
Re: Help with whirlpool connecting to php from SAMP -
kevin1990 - 05.03.2015
Jesus Christ that worked!!!!!
So weird. I have never had to use the tilda key for the query before. Could you tell me why that worked for future reference?!
BTW
I LOVE YOU!
AW: Re: Help with whirlpool connecting to php from SAMP -
Kaliber - 05.03.2015
Quote:
Originally Posted by kevin1990
Could you tell me why that worked for future reference?!
|
Because Key is a SQL Statement
With the `` you sign, that it should not be a statement, but a field