Php 更新集将错误的值传递到数据库

Php 更新集将错误的值传递到数据库,php,Php,我有下一个问题: 当使用php duplicate de+1到+2执行此查询时: "UPDATE usuario SET WRONG_LOGINS = WRONG_LOGINS + 1 WHERE USUARIO_CORREO = '" . $email . "'"; phpMyadmin工程: 0 = 0 + 1 1 = 1 + 1 2 = 2 + 1 在我的php方法中,出现了这样的情况:是加上一个数字 0 = 0 + 1 2 = 2 + 1 4 = 4 + 1 6 为什么会这样

我有下一个问题:

当使用php duplicate de+1到+2执行此查询时:

"UPDATE usuario SET WRONG_LOGINS = WRONG_LOGINS + 1 WHERE USUARIO_CORREO = '" . $email . "'";
phpMyadmin工程:

0 = 0 + 1 
1 = 1 + 1
2 = 2 + 1 
在我的php方法中,出现了这样的情况:是加上一个数字

0 = 0 + 1
2 = 2 + 1
4 = 4 + 1
6 
为什么会这样

我的代码:

public function usuarioLogin($email, $pass) {
        $con = $this->conectar();
        if (!$con) {
            return 0;
        } else {
            $query = "SELECT USUARIO_CODIGO, USUARIO_CORREO, COMUNA_CODIGO, EMPRESA_CODIGO, TUSUARIO_CODIGO, USUARIO_PASSWORD, "
                    . " USUARIO_NOMBRES, USUARIO_APELLIDOS, USUARIO_FNACIMIENTO, USUARIO_SEXO, USUARIO_DIRECCION,"
                    . " TEL_CELULAR, WRONG_LOGINS FROM usuario WHERE USUARIO_CORREO = '" . $email . "' and confirmed = 1 limit 1";
            $resultado = mysqli_query($con, $query);
            if ($resultado) {
                $user = $resultado->fetch_assoc();
                if (password_verify($pass, $user['USUARIO_PASSWORD'])) {
                    if ($user['WRONG_LOGINS'] <= 10) {
                        session_start();
                        session_regenerate_id();
                        $_SESSION['USUARIO_CODIGO'] = $user['USUARIO_CODIGO'];
                        $_SESSION['USUARIO_CORREO'] = $user['USUARIO_CORREO'];
                        $_SESSION['COMUNA_CODIGO'] = $user['COMUNA_CODIGO'];
                        $_SESSION['EMPRESA_CODIGO'] = $user['EMPRESA_CODIGO'];
                        $_SESSION['TUSUARIO_CODIGO'] = $user['TUSUARIO_CODIGO'];
                        $_SESSION["USUARIO_NOMBRES"] = $user["USUARIO_NOMBRES"];
                        $_SESSION["USUARIO_APELLIDOS"] = $user["USUARIO_APELLIDOS"];
                        $_SESSION["USUARIO_FNACIMIENTO"] = $user["USUARIO_FNACIMIENTO"];
                        $_SESSION["USUARIO_SEXO"] = $user["USUARIO_SEXO"];
                        return 1;
                    } else {

                        return 2;
                    }
                } else {
                    $this->registerWrongLoginAttemp($email);
                    return 3;
                }
            }
            $con->close();
        }
    }

public function registerWrongLoginAttemp($email) {
        //el update en vez de suma 1 suma 2
        $con = $this->conectar();
        if ($con) {
            $query = "UPDATE usuario SET WRONG_LOGINS = WRONG_LOGINS + 1 WHERE USUARIO_CORREO = '" . $email . "'";
            mysqli_query($con, $query);
        }
        $con->close();
    }
解决方案是将所有代码放入事件中,单击#提交表单:

$("#submitForm").on('click', function () {
                        var postEmail = $("#email").val();
                        var postPass = $("#password").val();
                        var parametros = {"email": postEmail, "password": postPass};
                        var formURL = $(this).attr("action");
                        $.ajax({
                            url: formURL,
                            type: "POST",
                            data: parametros
                        });
                        $("#loginForm").submit();
                    });

您用php编写的代码,show php code.看起来您执行了两次查询,您的页面可能执行了两次。使用浏览器的开发工具检查发送到网站的请求。谢谢,当我使用ajax调用时,这是我的代码问题
$("#submitForm").on('click', function () {
                        var postEmail = $("#email").val();
                        var postPass = $("#password").val();
                        var parametros = {"email": postEmail, "password": postPass};
                        var formURL = $(this).attr("action");
                        $.ajax({
                            url: formURL,
                            type: "POST",
                            data: parametros
                        });
                        $("#loginForm").submit();
                    });