27 lines
659 B
PHP
27 lines
659 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
|
|
require_once 'conexion.php';
|
|
if ($conexion->connect_error) {
|
|
echo json_encode(['success' => false, 'error' => 'Error de conexión']);
|
|
exit;
|
|
}
|
|
|
|
$data = json_decode(file_get_contents("php://input"), true);
|
|
$nombre = $data['nombre'] ?? '';
|
|
$telefono = $data['telefono'] ?? '';
|
|
|
|
$stmt = $conexion->prepare("INSERT INTO proveedores (Nombre, Telefono) VALUES (?, ?)");
|
|
$stmt->bind_param("ss", $nombre, $telefono);
|
|
|
|
if ($stmt->execute()) {
|
|
echo json_encode(['success' => true]);
|
|
} else {
|
|
echo json_encode(['success' => false, 'error' => $conexion->error]);
|
|
}
|
|
|
|
$stmt->close();
|
|
$conexion->close();
|
|
?>
|
|
|