<?php
include('is_logged.php');
require_once ("../config/db.php");
require_once ("../config/conexion.php");

$user_id = intval($_POST['user_id']);
$query = mysqli_query($con, "SELECT intentos FROM users WHERE user_id='$user_id'");
$row = mysqli_fetch_array($query);

if ($row) {
    $nuevo_valor = ($row['intentos'] == 1) ? 0 : 1;
    mysqli_query($con, "UPDATE users SET intentos='$nuevo_valor' WHERE user_id='$user_id'");
    echo json_encode(array('success' => true, 'nuevo_estado' => $nuevo_valor));
} else {
    echo json_encode(array('success' => false));
}
?>