'error', 'message' => 'All fields are required.']); exit; } // Append seconds to satisfy strict MySQL TIME column mode if (strlen($timeFrom) === 5) $timeFrom .= ':00'; if (strlen($timeTo) === 5) $timeTo .= ':00'; try { $stmt = $pdo->prepare("INSERT INTO room_restrictions (day_of_week, time_from, time_to) VALUES (?, ?, ?)"); $result = $stmt->execute([$day, $timeFrom, $timeTo]); if ($result) { echo json_encode(['status' => 'success', 'message' => 'Restriction saved successfully.']); } else { echo json_encode(['status' => 'error', 'message' => 'Failed to save: ' . implode(' ', $stmt->errorInfo())]); } } catch (Exception $e) { echo json_encode(['status' => 'error', 'message' => 'Exception: ' . $e->getMessage()]); }