36716-vm/update-coach-settings.php
2025-12-07 05:00:42 +00:00

25 lines
653 B
PHP

<?php
session_start();
require_once 'db/config.php';
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'coach') {
header('Location: login.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$coach_id = $_SESSION['user_id'];
$buffer_time = $_POST['buffer_time'] ?? 0;
$timezone = $_POST['timezone'] ?? 'UTC';
$pdo = db();
$stmt = $pdo->prepare("UPDATE coaches SET buffer_time = ?, timezone = ? WHERE id = ?");
$stmt->execute([$buffer_time, $timezone, $coach_id]);
header('Location: dashboard.php?status=settings_updated');
exit;
} else {
header('Location: dashboard.php');
exit;
}