File "update_observaciones.php"
Full Path: C:/wamp64/www/RegistroEquipos2/backend/mantenimiento/update_observaciones.php
File size: 1.15 KB
MIME-type: text/x-php
Charset: utf-8
<?php
session_start();
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, OPTIONS');
$host = '192.200.100.40';
$db = 'sistemas';
$user = 'SANMARINO';
$pass = 'sanmarino2021*';
try {
$pdo = new PDO("mysql:host=$host;dbname=$db;charset=utf8mb4", $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
]);
$data = json_decode(file_get_contents('php://input'), true);
if (!$data) {
echo json_encode(['status' => 'error', 'mensaje' => 'Datos no vĂ¡lidos']);
exit;
}
$id = $data['id'] ?? 0;
$observaciones = $data['observaciones'] ?? '';
if (!$id) {
echo json_encode(['status' => 'error', 'mensaje' => 'ID no proporcionado']);
exit;
}
$stmt = $pdo->prepare("UPDATE mantenimientos SET observaciones = ? WHERE id = ?");
$stmt->execute([$observaciones, $id]);
echo json_encode(['status' => 'success', 'mensaje' => 'Observaciones actualizadas correctamente']);
} catch (PDOException $e) {
echo json_encode(['status' => 'error', 'mensaje' => $e->getMessage()]);
}
?>