Hey I'm trying to get a login working where the passwords have been hashed. I have it working when the passwords are hashed but can't seem to get it working when they are. It give me the error "Sorry, your username or password are incorrect". Any pointers to where I might have gone wrong? It connects to the db correct I just took them details out of the "".
Below is my checklogin php
<?php
$host = ""; // Host name
$username = "root"; // Mysql username
$password = ""; // Mysql password
$db_name = "login"; // Database name
$tbl_name = "tbl_pswd"; // Table name
mysql_connect("", "root", "") or die("cannot connect");
mysql_select_db("login") or die("cannot select DB");
$username = $_POST['username'];
$passowrd = sha1($_POST['password']);
$sql = "(SELECT username FROM tbl_pswd WHERE username = '$username' AND password = '$password')";
$result = mysql_query($sql);
if (mysql_num_rows($result) < 1) {
echo 'Sorry, your username or password was incorrect!';
} else {
printf('welcome back %5s!', $_POST['username']);
}
?>
Here is my HTML form incase it also helps
<html>
<head>
<title>Login</title>
<h1> Login Menu </h1>
</head>
<body>
<form name="form1" method="post" action="checklogin.php">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit" value="Submit">
</form>
</body>
</html>
Thanks for any help!