Code on my register page:
$p_salt = rand_string(20);
$site_salt="subinsblogsalt"; /*Common Salt used for password storing on site.*/
$salted_hash = hash('sha256', $password.$site_salt.$p_salt);
I then insert the salt in to the database, along with the salted passwords, but when I do it on my login page:
if(isset($_POST) && $email!='' && $password!=''){
$sql=$dbh->prepare("SELECT id,password,psalt FROM user WHERE email='".$email."'");
$sql->execute(array($email));
while($r=$sql->fetch()){
$p=$r['password'];
$p_salt=$r['psalt'];
$id=$r['id'];
}
$site_salt="subinsblogsalt";/*Common Salt used for password storing on site. You can't change it. If you want to change it, change it when you register a user.*/
$salted_hash = hash('sha256', $password.$site_salt.$p_salt);
But they don't match at all, I echoed the salted hash to compare it to the one in the database but they're different.