使用 php 的激活密钥问题

发布于 2024-11-03 06:26:59 字数 511 浏览 4 评论 0原文

我正在为我的 WordPress 安装使用自定义登录脚本。一切工作正常,除了当激活密钥以以下格式发送给注册用户时:

http://mydomain.com/?page_id=1278&[email protected]&activate_key=7edbad

但是,当用户单击上述链接时,电子邮件中的“@”消失,因此给出激活密钥无效的错误。

有人可以指导我吗?

这是将激活链接放在一起的代码片段:

$link=get_option('home').'/?page_id='.$pageid.'&mail='.$user_email.'&activate_key='.$key;

I'm using a custom login script for my wordpress installation. Everything works fine except that when the activation key is sent to registered users in the following format:

http://mydomain.com/?page_id=1278&[email protected]&activate_key=7edbad

When users click on the above link however, the '@' in the email disappears and therefore gives an error that the activation key is invalid.

Can someone guide me on this?

This is the piece of code that puts the activation link together:

$link=get_option('home').'/?page_id='.$pageid.'&mail='.$user_email.'&activate_key='.$key;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

诺曦 2024-11-10 06:26:59

您可能需要使用 urlencode() 对该 URL 中的参数进行编码 每个参数值的函数:

$link=get_option('home')
            .'/?page_id='.urlencode($pageid)
            .'&mail='.urlencode($user_email)
            .'&activate_key='.urlencode($key);

As an alternative, you could also use [**`http_build_query()`**][2] once, to build up the whole query string :

$params = array(
    'page_id' => $pageid, 
    'mail' => $user_email, 
    'activate_key' => $key, 
);
$query_string = http_build_query($params);

$link=get_option('home') . '/?' . $query_string;

You probably need to encode the parameters in that URL, using the urlencode() function on each parameter's value :

$link=get_option('home')
            .'/?page_id='.urlencode($pageid)
            .'&mail='.urlencode($user_email)
            .'&activate_key='.urlencode($key);

As an alternative, you could also use [**`http_build_query()`**][2] once, to build up the whole query string :

$params = array(
    'page_id' => $pageid, 
    'mail' => $user_email, 
    'activate_key' => $key, 
);
$query_string = http_build_query($params);

$link=get_option('home') . '/?' . $query_string;
陈甜 2024-11-10 06:26:59

在 GET 参数上尝试 urlencode()

Try urlencode() on the GET params.

万劫不复 2024-11-10 06:26:59

尝试将 $user_email 周围的 urlencode() 将其转换为 URL 友好的值。

Try urlencode() around the $user_email to convert it to a URL-friendly value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文