34849-vm/save_banner_text.php
2026-02-05 06:00:56 +00:00

31 lines
958 B
PHP

<?php
require_once 'db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$banner_text = $_POST['banner_text'] ?? '';
try {
$pdo = db();
// Use INSERT ... ON DUPLICATE KEY UPDATE to either create or update the banner text
$sql = "INSERT INTO configuracion (clave, valor) VALUES (:clave, :valor)
ON DUPLICATE KEY UPDATE valor = :valor";
$stmt = $pdo->prepare($sql);
$stmt->execute([
':clave' => 'banner_text',
':valor' => $banner_text
]);
// Redirect back to the info page
header('Location: configuracion.php');
exit;
} catch (PDOException $e) {
// For a real app, you might log this error and show a user-friendly message
die("Error al guardar en la base de datos: " . $e->getMessage());
}
} else {
// If not a POST request, just redirect away
header('Location: info_producto.php');
exit;
}