File "telefonoid.php"
Full Path: C:/wamp64/www/RegistroEquipos/backend/telefono/telefonoid.php
File size: 1.27 KB
MIME-type: text/x-php
Charset: utf-8
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
$host = '192.200.100.40';
$db = 'sistemas';
$user = 'SANMARINO';
$pass = 'sanmarino2021*';
$charset = 'utf8mb4';
try {
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$pdo = new PDO($dsn, $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
$id = $_GET['id'] ?? 0;
if (!$id) {
echo json_encode(['status' => 'error', 'mensaje' => 'ID no proporcionado']);
exit;
}
// Incluir imagen e imagen_2 en la consulta
$sql = "SELECT marca, referencia, color, imei, imagen, imagen_2 FROM inventario_telefonos WHERE id = :id";
$stmt = $pdo->prepare($sql);
$stmt->execute([':id' => $id]);
$telefono = $stmt->fetch(PDO::FETCH_ASSOC);
if ($telefono) {
echo json_encode([
'status' => 'success',
'data' => $telefono
]);
} else {
echo json_encode(['status' => 'error', 'mensaje' => 'Teléfono no encontrado']);
}
} catch (PDOException $e) {
echo json_encode([
'status' => 'error',
'mensaje' => 'Error en base de datos: ' . $e->getMessage()
]);
}
?>