<?php
// File: admin/simpan_pengumuman.php
session_start();
if (!isset($_SESSION['admin'])) {
  header("Location: login.php");
  exit;
}

include '../config/koneksi.php';

// Validasi input
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  $link  = mysqli_real_escape_string($conn, $_POST['link_grup_wa']);
  $nomor = mysqli_real_escape_string($conn, $_POST['nomor_panitia']);

  // Simpan data – hapus dulu karena hanya satu baris yang digunakan
  $delete = mysqli_query($conn, "DELETE FROM pengaturan_pengumuman");
  $insert = mysqli_query($conn, "INSERT INTO pengaturan_pengumuman (link_grup_wa, nomor_panitia) VALUES ('$link', '$nomor')");

  // Redirect setelah sukses
  header("Location: diterima.php");
  exit;
} else {
  // Jika akses langsung tanpa POST, kembalikan
  header("Location: diterima.php");
  exit;
}
