PHP isset GET中唯一标识符链接值接收失败

我正在尝试通过电子邮件验证注册,并向用户发送唯一标识符链接。

我从远程服务器使用它。服务器、用户名、密码、数据库值正确,与其他.php-s一起工作正常,只有不同之处verify.php包括连接,而不是 require 'connection.php';,但我不确定连接是否会产生以下故障。

发送:

$message = "<p>Hello, dear $user</p><a href='https://mypage.info/php/reg/verify.php?vkey=$vkey'>Confirm Account</a>";

并通过电子邮件接收:

https://mypage.info/php/reg/verify.php?vkey=4bf65cf02210b304143589e6dc3714c0

链接到verify.php,但php会抛出Something went wrong,或者如果相反,die我将检查echo 'VKey: '. $vkey;或不echo $mysqli->error;显示任何内容。

似乎由于某种原因if (isset($_GET['vkey']))没有vkey正确接收。我不确定我在这里做错了什么:


慕田峪9158850
浏览 145回答 2
2回答

DIEA

建议:尽可能使用仪器,并将您发现的内容发回。例如:<?php&nbsp; echo "vkey=" . $_GET['vkey'] . "...<br/>";&nbsp; if (isset($_GET['vkey'])) {&nbsp; &nbsp; &nbsp;$vkey = $_GET['vkey'];&nbsp; &nbsp; &nbsp;echo "vkey=" . $vkey . "...<br/>";&nbsp; &nbsp; &nbsp;$mysqli = NEW MySQLi ('server','username','password','db');&nbsp; &nbsp; &nbsp;echo "mysqli: SUCCEEDED...<br/>";&nbsp; &nbsp; &nbsp;$resultSet = $mysqli->query("SELECT verified, vkey FROM registration WHERE verified = 0 AND vkey = '$vkey' LIMIT 1");&nbsp; &nbsp; &nbsp;echo "resultSet: SUCCEEDED...<br/>";&nbsp; &nbsp; &nbsp;echo "resultSet->num_rows=" . $resultSet->num_rows . "...<br/>";&nbsp; &nbsp; &nbsp;if ($resultSet->num_rows == 1)&nbsp; &nbsp; &nbsp;{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$update = $mysqli->query("UPDATE registration SET verified = 1 WHERE vkey = '$vkey' LIMIT 1");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "update: SUCCEEDED...<br/>");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if($update){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Your account has been verified. You may now login.";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo $mysqli->error;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp; &nbsp; &nbsp;}&nbsp;&nbsp; &nbsp; &nbsp;else&nbsp;&nbsp; &nbsp; &nbsp;{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "This account invalid or already verified";&nbsp; &nbsp; &nbsp;}&nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; echo "ERROR STATE: " . $mysqli->error . "...<br/>";&nbsp; &nbsp; &nbsp;die("Something went wrong");&nbsp; }?>不,我想不出“......为什么 md5 字符串”可能是罪魁祸首。但我认为上述工具(或类似工具)可能会帮助我们确定问题发生的确切位置……以及如何解决它。'希望有帮助...

慕斯王

您的代码在 $_POST 数组中而不是 $_GET 中查找&nbsp; if (isset($_GET['vkey'])) {&nbsp; &nbsp; &nbsp;$vkey = $_GET['vkey'];
打开App,查看更多内容
随时随地看视频慕课网APP