Would the following be a safe way of storing a user's password in a database?
When registering:
$salt=hash("sha512", rand());
$password=hash("sha512", $_POST["password"].$salt);
insert_values_into_db;
When logging in:
$given_password=$_POST["password"];
$salt=get_salt_from_db;
$correct_password=get_password_from_db;
if(hash("sha512", $given_password.$salt) === $correct_password){
//Password is correct
}else{
//Password is incorrect
}
Are there any blatantly obvious errors with this?