繁体   English   中英

尝试在PHP中更新查询时出现内部服务器错误

[英]Internal Sever error when trying to update query in PHP

实际上是在构建登录和注册系统,但是如果用户的email和email_code匹配,则试图将active表更改为1时,电子邮件激活部分会出现这些内部错误。

activate.php代码:

<?php

} else if (isset($_GET['email'], $_GET['activation']) === true) {

    $email      = trim($_GET['email']);
    $email_code = trim($_GET['activation']);

    if (email_exists($email) == false) {
        $errors[] = 'Ooops, We counldn\'t find that email address';

    } else if (activate($email, $email_code) == false) {
        $errors[] = 'Ooops, We had problem activating your account';

    }

    if (empty($errors) == false){
        echo output_errors($errors) . '<br><br>'; 
    } else {
        header('Location : activate.php?success');
        exit();
    }

} else {

    header('Location: index.php');
    exit();
}

?>

activate($ email,$ email_code)函数:

function activate($email, $email_code) {
    global $connection;

    $email      = $email;
    $email_code = $email_code;
    $active     = 0;
    $new_update_active = 1;

    $stmt       = $connection -> prepare('SELECT id FROM users WHERE email = ? AND email_code = ? AND active = ?');

    $stmt -> bind_param('ssi', $email, $email_code, $active);
    $stmt -> execute();
    $stmt -> store_result();
    $stmt -> fetch();

    if ($stmt -> num_rows() == 1) {

        $update_active = $connection -> prepare('UPDATE users SET active = ? WHERE email = ?');
        $update_active -> bind_param('is', $new_update_active, $email);
        return true;

    } else {
        return false;
    }

}

错误: 错误图片!!

该代码似乎是正确的,并且仅在涉及emailemail_code匹配的部分并将email_code中的active表更改为1时才具有这些内部服务。

后来我发现了错误,我只是改变了

header('Location : activate.php?success');

header('Location: activate.php?success');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM