Reputation: 684
EDITED TO ADD MORE INFO
I need to use mysql's md5 function to select an item using it's id field (uid
). I have a separate database from my users called recover_db
that has an md5 hashed value of the user id in it and a time stamp.
Currently the users visit a link like this:
recover-MD%HASHEDUSERID.html
Then the system takes that MD%HASHEDUSERID
from the url and checks if it exists in the recover_db
and if it does it lets them recover the account. There's some other stuff for security and whatnot but I do not store the user id in the recover_db
, just the MD5 value of it. I use the following to do that:
md5(90*13/12*56+$id)
Now I need to check the users database and get the REAL account id using the md5 value I have saved. I was using the following query to do this:
$query = "SELECT uid FROM users where md5(90*13/12*56+uid)='".$md5accID."'";
Unfortunately this is returning no results. Is there any way to get the real user id from the users
database using the md5 version of it from the recover_db
? I want to avoid storing the user id in the recover_db
if I can.
Upvotes: 0
Views: 467
Reputation: 1057
Save the original user ID in a field origuid
together with the hash (hasheduid
) in the recovery database. Then do
$query = "SELECT origuid FROM users where hasheduid='".$md5accID."'";
to retrieve the original user ID.
Upvotes: 1