php - 与链接连接时出现连接无法正常工作的问题
问题描述
您好,当我使用 php 将代码与 phpmailer 中的链接连接起来时,为什么它不起作用?
这是我尝试过的两种方法。
这种连接方法不会将 $userverifcationCode 与链接连接,但是当我复制链接并输入它时,它可以工作。但是,如果你只是要复制它,那就很麻烦了。
'http://localhost/Bloodlad/user/verificationForgot.php?code='.$user_verificationCode;
这种连接方法有效,但是当我单击链接时,它正在回显无效代码。
'http://localhost/Bloodlad/user/verificationForgot.php?code='.trim($user_verificationCode);
方法一验证码:http://localhost/Bloodlad/user/verificationForgot.php?code=xGLNJM
方法二验证码:http://localhost/Bloodlad/user/verificationForgot.php?code=SN6Wqq
Method1&2 图片 这是验证代码的代码。
$code = $_GET['code'];
$sql="SELECT * FROM users WHERE user_verificationCode=?";
$stmt=$conn->prepare($sql);
$stmt->bind_param("s", $code);
$stmt->execute();
$result=$stmt->get_result();
$row=$result->fetch_assoc();
$count=$result->num_rows;
if($count > 0){
$user_isVerified='Yes';
$user_verificationCode="";
$sql="UPDATE users SET user_isVerified=?, user_verificationCode=? WHERE user_verificationCode=?";
$stmt=$conn->prepare($sql);
$stmt->bind_param("sss", $user_isVerified, $user_verificationCode, $code);
if($stmt->execute()){
echo 'You have successfuly verified your account <br>';
echo '<a href="login.php">Click this link to login</a>';
}
}else{
echo 'Invalid verification code';
}
$code 是验证码。它位于verificatonForgot.php?=code 之后。
$mail->Body = 'http://localhost/Bloodlad/user/verificationForgot.php?code='.$user_verificationCode;
我使用的 PHP 版本是 PHP 7.4.23 / PHP 7.4.23
解决方案
正确编码 URL 的该部分,例如:
$mail->Body = 'http://localhost/Bloodlad/user/verificationForgot.php?code='.rawurlencode($user_verificationCode);
推荐阅读
- javascript - JS 代码(Chrome 开发工具)仅在 Instagram 标签搜索上显示视频
- c# - 为什么 LINQ 查询会影响原始列表?
- c++ - 这两种方式有什么区别?
- python - Better way to timestamp a file write
- python - 如何使用opencv和python获取平面图中每个房间的主要方向?
- c# - 忽略或重定向 xmlns
- selenium - python selenium一个一个地单击复选框,而不是全部一起
- c - 可以对数组进行排序以使 bsearch 工作吗?
- hadoop - “YARN”模式不适用于 Hadoop YARN 集群
- forms - 静态网站、文件上传和重新验证