<?php
// checkLogin.php
session_start(); // Start a new session
require('conn.php'); // Holds all of our database connection information
// Get the data passed from the form
$username = $_POST['user'];
$password = $_POST['password'];
// Do some basic sanitizing
$username = stripslashes($username);
$password = stripslashes($password);
$sql = "select * from players where user = '$username' and pass = '$password'";
$result = mysql_query($sql) or die ( mysql_error() );
$count = 0;
while ($line = mysql_fetch_assoc($result)) {
$count++;
}
if ($count == 1) {
$_SESSION['loggedIn'] = "true";
header("Location: loginSuccess.php"); // This is wherever you want to redirect the user to
} else {
$_SESSION['loggedIn'] = "false";
header("Location: loginFailed.php"); // Wherever you want the user to go when they fail the login
}
?>
<?php
// checkLogin.php
session_start(); // Start a new session
require('conn.php'); // Holds all of our database connection information
// Get the data passed from the form
$username = $_POST['user'];
$password = $_POST['password'];
// Do some basic sanitizing
$username = stripslashes($username);
$password = stripslashes($password);
$sql = "select * from players where user = '$username' and pass = SHA('$password')"; // Thats all
$result = mysql_query($sql) or die ( mysql_error() );
$count = 0;
while ($line = mysql_fetch_assoc($result)) {
$count++;
}
if ($count == 1) {
$_SESSION['loggedIn'] = "true";
header("Location: loginSuccess.php"); // This is wherever you want to redirect the user to
} else {
$_SESSION['loggedIn'] = "false";
header("Location: loginFailed.php"); // Wherever you want the user to go when they fail the login
}
?>
<?php
// checkLogin.php
session_start(); // Start a new session
require('conn.php'); // Holds all of our database connection information
// Get the data passed from the form
$username = $_POST['user'];
$password = $_POST['password'];
// Do some basic sanitizing
$username = stripslashes($username);
$password = stripslashes($password);
function Whirlpool($str)
{
return strtoupper(hash('whirlpool', $str));
}
$sql = "select * from players where user = '$username' and pass = Whirlpool('$password')";
$result = mysql_query($sql) or die ( mysql_error() );
$count = 0;
while ($line = mysql_fetch_assoc($result)) {
$count++;
}
if ($count == 1) {
$_SESSION['loggedIn'] = "true";
header("Location: loginSuccess.php"); // This is wherever you want to redirect the user to
} else {
$_SESSION['loggedIn'] = "false";
header("Location: loginFailed.php"); // Wherever you want the user to go when they fail the login
}
?>
Just provides an implementation of the whirlpool hash algorithm for PAWN |
$password = hash("whirlpool",mysqli_real_escape_string($_POST["password"])); |
That's actually less useful than it sounds - you can never trust anything coming from the client, so you can't assume the javascript hashed correctly and wasn't compromised, or even that the JS ran at all (since people can have it disabled).
|
True, but actually you cant even trust the server, or ssl right now. The plain password can get compromised exactly the same way, it doesnt matter if attackers fake the password hash or the password itself. So I dont see any real disadvantages from this, but giving the user some more privacy is a pretty big advantage.
Edit: Sure, the hashing shouldnt be only on the client, but hashing it twice isnt a problem, its just about not revealing the users plain password. |
Originally Posted by xkirill
$password = hash("whirlpool",mysqli_real_escape_string($_POST["password"]));
|
$password = hash('whirlpool', $mysqli->real_escape_string($_POST['password']));
Again, there's no need to escape a password you are hashing, since you are then hashing it which removes any additional characters anyway. If you REALLY want to worry about PHP security, check the input is a string not an array.
|
Why can't you trust SSL? The Heartbleed incident had to do with a vulnerable version of OpenSSL. As long as you don't use a vulnerable version, you're fine. I'd trust a website that actually uses SSL way more than a site that doesn't, but simply throws together some Javascript code that I could manipulate with ease.
|
The downside is that locks out anyone without javascript, instead of relying solely on the server you control so know what is running.
|
The downside is that locks out anyone without javascript, instead of relying solely on the server you control so know what is running.
|