27 lines
610 B
PHP
27 lines
610 B
PHP
<?php
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
require_once '../db/config.php';
|
|
|
|
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
|
header('Location: challenges.php');
|
|
exit();
|
|
}
|
|
|
|
$challenge_id = $_GET['id'];
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare('UPDATE challenges SET deleted_at = CURRENT_TIMESTAMP WHERE id = ?');
|
|
if ($stmt->execute([$challenge_id])) {
|
|
header('Location: challenges.php?deleted=true');
|
|
exit;
|
|
} else {
|
|
header('Location: challenges.php?error=true');
|
|
exit;
|
|
}
|