Files
yogibook_aury_new/public/options_save.php
T

34 lines
1.0 KiB
PHP

<?php
require_once('include/headscript.php');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header("Location: options.php");
exit();
}
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
header("Location: options.php?message=error");
exit();
}
// Checkbox non spuntata = nessun invio -> default 'N'
$waitingEnabled = (isset($_POST['waitinglist_enabled']) && $_POST['waitinglist_enabled'] === 'Y') ? 'Y' : 'N';
$maxCancel = isset($_POST['maxbeforetimecancell']) ? (string) (int) $_POST['maxbeforetimecancell'] : '0';
// Aggiorna l'unico record di option (idption = 1)
$stmt = $conn->prepare("UPDATE `option` SET waitinglist_enabled = ?, maxbeforetimecancell = ? WHERE idption = 1");
$stmt->bind_param("ss", $waitingEnabled, $maxCancel);
if ($stmt->execute()) {
$stmt->close();
$conn->close();
header("Location: optionsschool.php?message=success");
exit();
} else {
$stmt->close();
$conn->close();
header("Location: optionsschool.php?message=error");
exit();
}