【发布时间】:2017-05-20 02:03:13
【问题描述】:
这里是 mysql_* 代码:
Activation mail and hash check
PDO:
有人看到解决方案吗?
if (isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash'])){
// Verify data
$search = $db->prepare("SELECT email, hash, active FROM users WHERE email=:email AND hash=:hash AND active=0");
$search->bindParam(':email', $_POST['email'], PDO::PARAM_STR);
$search->bindParam(':hash', $_POST['hash'], PDO::PARAM_STR);
$search->execute();
//$match = $search->fetch(PDO::FETCH_ASSOC);
$match = $search->rowCount();
这部分条件有问题
if($match > 0){
// We have a match, activate the account
$db->prepare("UPDATE users SET active= 1 WHERE email=:email AND hash=:hash AND active=0");
$db->bindParam(':email', $_POST['email'], PDO::PARAM_STR);
$db->bindParam(':hash', $_POST['hash'], PDO::PARAM_STR);
$db->execute();
echo '<div class="statusmsg">Your account has been activated, you can now login</div>';
}else{
// No match -> invalid url or account has already been activated.
echo '<div class="statusmsg">The url is either invalid or you already have activated your account.</div>';
}
}else{
// Invalid approach
echo '<div class="statusmsg">Invalid approach, please use the link that has been send to your email.</div>';
}
条件结束这里的代码:
网址无效或您已激活帐户。
但它应该在这里完成代码:
您的帐户已激活,您现在可以登录了。
【问题讨论】:
-
你面临的问题是你没有得到你需要的结果吗?
-
你的问题是什么
-
你是如何散列的?
-
代码在 mysql_* 中完美运行,但在 PDO 中无法运行,某处出现错误 stackoverflow.com/questions/43986473/…
-
阅读全文,你就会明白这个问题!