【发布时间】:2019-02-15 03:57:51
【问题描述】:
我有一个用户数据库,我想为用户发送一封包含一些独特参数的电子邮件。
我将用户 ID、电子邮件、姓名和 2 个字段存储在数据库中。
我正在考虑同时使用 id 和 email 来创建唯一的两个参数,例如使用哈希/加密/随机播放。
比如md5(我知道它不安全,但那不是密码)、uniquid、..等等。
$uniquId = uniquid( $id );
$uniquEmail = md5( $email );
$URL = 'www.example.com/page.php?u='.$uniquId.'&e='.$uniquEmail;
在page.php:
$id = $_GET['u'];
$email = $_GET['e'];
//Check if these values exist in the DB, If exists show the page, Else redirect the user
但是如果那个随机字符串包含&Ugeb=kijd,那么 URL 看起来像:www.example.com/page.php?u=26737&e=IKd752&uTehD=Hye3,那么$_GET['e'] 将是IKd752 对吗?
如果是这样,创建这 2 个唯一参数的最佳方法是什么?
【问题讨论】:
-
只需将 str_replace 删除结果字符串中的所有 & 和 = 字符
标签: php encryption random hash