I have a form for updating user data. He publishes this page:
<?php //Update user table session_start(); include 'sql_connect_R.inc.php'; $id = mysql_real_escape_string($_POST['userID']); $password = mysql_real_escape_string($_POST['user_passwrd']); $salt = time(); $hash = sha1($password . $salt); mysql_query("UPDATE users SET user_passwrd = '$hash', stamp = '$salt', pending = 'yes' WHERE userID = '$id'"); mysql_close($con); ?>
(I edited things not related to this question)
I believe what happens when the stamp field is filled with $ salt, it gets a different value than when the $ hash is calculated. Therefore, when a user registers and checks here:
$qry="SELECT * FROM users WHERE userlogin = '$login' AND user_passwrd = sha1(CONCAT('$password', stamp))"; $result=mysql_query($qry); $row = mysql_fetch_assoc($result); $num = mysql_num_rows($result);
When I return $ num, it returns 0. I wonder if there is a way to guarantee that the value of $ salt remains unchanged when it is used in the $ hash, and then when it updates the stamp field. Can someone help me with this or point me in the right direction? Thanks in advance. Greetings
source share