Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为每个用户发送带有唯一参数的URL_Php_Encryption_Random_Hash - Fatal编程技术网

Php 为每个用户发送带有唯一参数的URL

Php 为每个用户发送带有唯一参数的URL,php,encryption,random,hash,Php,Encryption,Random,Hash,我有一个用户数据库,我想为用户发送一封电子邮件,其中将包含一些独特的参数 我有用户id、电子邮件、姓名和2个字段,将这些唯一参数存储在数据库中 我正在考虑使用id和email来创建两个唯一的参数,就像使用散列/加密/洗牌一样 比如md5(我知道它不安全,但这不是密码),uniquid,等等 $uniquId = uniquid( $id ); $uniquEmail = md5( $email ); $URL = 'www.example.com/page.php?u='.$uniquId.'

我有一个用户数据库,我想为用户发送一封电子邮件,其中将包含一些独特的参数

我有用户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
,那么
$\u GET['e']
就只有
IKd752
了,对吗


如果是这样,创建这两个唯一参数的最佳方法是什么?

您可以使用
time()
函数获得唯一的整数,然后您可以将其与常数相乘,以使数字变长。此方法唯一的问题是,您的密钥将只包含数字。

Str_replace(如第一位评论员所建议的)和Str_split可删除不需要的字符串。

只需Str_replace可删除结果字符串中的所有&and=字符