File "lineaid.php"
Full Path: C:/wamp64/www/RegistroEquipos2/backend/telefono/lineaid.php
File size: 1.19 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;
}
$sql = "SELECT numero, plan_datos, operador FROM inventario_lineas WHERE id = :id";
$stmt = $pdo->prepare($sql);
$stmt->execute([':id' => $id]);
$linea = $stmt->fetch(PDO::FETCH_ASSOC);
if ($linea) {
echo json_encode([
'status' => 'success',
'data' => $linea
]);
} else {
echo json_encode(['status' => 'error', 'mensaje' => 'LĂnea no encontrada']);
}
} catch (PDOException $e) {
echo json_encode([
'status' => 'error',
'mensaje' => 'Error en base de datos: ' . $e->getMessage()
]);
}
?>