[英]MySQL query not updating after but PHP shows no errors
這用於用戶激活。
function activate($email, $email_code){
$email = mysql_real_escape_string($email);
$email_code = mysql_real_escape_string($email_code);
if (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email' AND `email_code` = '$email_code' AND `active` = 0"), 0) == 1){
mysql_query("UPDATE `users` SET `active` = 1 WHERE `email` = '$email'");
return true;
}else{
return false;
}
}
Activation.php
if (isset($_GET['success']) === true && empty($_GET['success'])===true){
echo 'Account activated!';
}
else if (isset($_GET['email'], $_GET['email_code']) === true){
$email = trim($_GET['email']);
$email_code = trim($_GET['email_code']);
if(email_exists($email) === false){
$errors[] = 'Oops, something went wrong!';
}else if (activate($email, $email_code === false)){
$errors[] = 'We have problems activating your account!';
}
if (empty($errors) === false){
echo output_errors($errors);
}else{
header('Location:activate.php?success');
exit();
}
}else{
header('Location:go.php');
exit();
}
上面寫着“帳戶已激活!” 正如我的回應,但它並沒有改變表格中的字段。 它根本沒有激活。 這里有什么問題?
您必須像這樣更改功能
function activate($email, $email_code){
$email = mysql_real_escape_string($email);
$email_code = mysql_real_escape_string($email_code);
if (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email' AND `email_code` = '$email_code' AND `active` = 0"), 0) == 1){
if(mysql_query("UPDATE `users` SET `active` = 1 WHERE `email` = '$email'")){
return true;
}
else{
return false;
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.