<?php
session_start();
if (!isset($_SESSION['user'])) {
  // jika user belum login
  header('Location: ../login');
  exit();
}

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

// ambil data dari form
$id_pelatih = htmlspecialchars($_GET['id_pelatih']);


// delete database
$query = "DELETE FROM pelatih WHERE id_pelatih = $id_pelatih";

$hasil = mysqli_query($db, $query);

// cek keberhasilan pendambahan data
if ($hasil == true) {
  echo "<script>window.location.href='../pelatih'</script>";
} else {
  echo "<script>window.alert('Foto gagal dihapus!'); window.location.href='../pelatih'</script>";
}
