doulou9927 2016-11-16 07:56
浏览 51
已采纳

使用md5版本的id查询字段

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.

  • 写回答

1条回答 默认 最新

  • dro80463 2016-11-16 08:02
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部