gpt4 book ai didi

php - 电子邮件激活链接无法按预期工作

转载 作者:行者123 更新时间:2023-11-29 16:02:08 25 4
gpt4 key购买 nike

我有一个注册和登录系统,在某种程度上运行良好。用户注册后,系统会发送一封包含激活码的电子邮件。预期的行为是,单击电子邮件激活链接后,我的数据库中已注册但未经验证的“状态”列将从默认整数值 0 重置为 1。但是,“状态”仅在发送电子邮件时更新,而不需要用户必须点击激活链接!

我搜索了 Stack Overflow 网站,查看了教程,并对代码尝试了多种排列,但没有成功。

    if (isset($_GET['email']) AND isset ($_GET['vkey'])){

if ($stmt = $link->prepare('SELECT email, vkey FROM members WHERE email = ? AND vkey = ?')) {
$stmt->bind_param('ss', $_GET['email'], $_GET['vkey']);
$stmt->execute();
// Store the result so we can check if the account exists in the database.
$stmt->store_result();
if ($stmt->num_rows ==1) {


if ($stmt = $link->prepare('UPDATE members SET status = 1 WHERE email = ? AND vkey = ?')) {
// Set status to 1
//$status = 1;
$stmt->bind_param('ss', $_GET['email'], $_GET['vkey']);
$stmt->execute();
echo 'Your account is now activated. You can now login.<br><a href="login.php">Login</a>';
}
} else {
echo 'Your account is already activated or doesn\'t exist!';
}
}

我希望仅当用户单击电子邮件中的验证链接时数据库“状态”列才会更新,但它会在电子邮件发送后立即更新。

最佳答案

确保您发送电子邮件所用的 API 没有点击电子邮件内的链接。一些电子邮件提供商会这样做。

您可以通过记录请求并在单击链接之前检查是否调用来进行检查。

关于php - 电子邮件激活链接无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56099383/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com