I have a MySQL 'users' table with the following columns: uname , hash, salt and pwd. I'm testing a PHP log in page that uses this table to gain user access. I don't yet have the system setup to register users at the moment so testing by adding data manually to the table with the following.....
uname: 'testuser',
pwd: 'password'
the php function that deals with checking the password is below:
function checkPwd($uname, $pwd){
    // Get the hash and salt for this user:
    $q = "SELECT hash, salt FROM users WHERE uname = '".mysql_real_escape_string($uname)."';";
    $res = mysql_query($q) or die("Could not retrieve user login data " . mysql_error());
    $tmp = mysql_fetch_assoc($res);
    $hash = $tmp['hash'];
    $salt = $tmp['salt'];
    // Hash and salt $pwd so we can make a comparison:
    $hashedInput = sha1($salt . $pwd);
    if($hash == $hashedInput) return true; // Return true if the hashed and salted $pwd matches DB entry
    return false;
}
Its not working obviously, the thing is I'm not really understanding the hash and salt way of doing things. How can I test my log in page keeping things secure with the function above. Do I have to enter anything in the salt and hash fields?
 
     
     
     
     
     
    