Jump to content
Larry Ullman's Book Forums

Question About Update Query And Sha1() Function


Recommended Posts

When changing a user password, I noticed that my UPDATE query (below) will not work if the user types in the same password as exists in the database. Otherwise it works okay. I don't know why.

 

$q = "UPDATE ".DBTABLE." SET pass=SHA1('$np')

WHERE maaMembersID = ".$id;

 

when $np is the same as the old password, this does not work.

Link to comment
Share on other sites

Since the value hasn't changed MySQL will not update the row, thereby returning zero rows and the check

if (mysqli_num_rows($r) == 1)

will fail. You can force the user to change his password to a new value and in the form validation check that the new value is not equal to the current value.

Link to comment
Share on other sites

Thank you. I thought that might be the case but never really knew for sure. It was a problem because, even with no errors turned on, I was getting the UPDATE query printed to the screen along with my own nebulous "system error" warning under the condition that

mysqli_num_rows($r) != 1

So, no problem, I just take care of it in the validation.

thanks again

Link to comment
Share on other sites

 Share

×
×
  • Create New...