30.05.2014, 07:38
How do I hash this script (login Script)
PHP код:
<?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
}
?>