0

这是为了用户激活。

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;
    }
}

激活.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();
}

它说“帐户已激活!” 正如我回应的那样,但它并没有改变表中的字段。基本没有激活。这里有什么问题?

4

1 回答 1

0

您必须像这样更改功能

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;
    }
  }
}
于 2013-01-12T07:50:57.463 回答