<?php
$r = "../";
require_once($r."inc/funciones.php");
$mysqli = connectDB($r);

header('Content-Type: text/plain; charset=utf-8');

if (isset($_POST['id'])) {
    $id = intval($_POST['id']);

    // reactivar: estado=1, eliminado=0
    $sql = "UPDATE z_productos SET estado=1, eliminado=0 WHERE id=? LIMIT 1";
    if ($stmt = $mysqli->prepare($sql)) {
        $stmt->bind_param("i", $id);
        if ($stmt->execute() && $stmt->affected_rows >= 0) {
            echo "ok";
        } else {
            echo "error";
        }
        $stmt->close();
    } else {
        echo "error";
    }
} else {
    echo "error";
}

$mysqli->close();
