36806-vm/delete_activity.php
Flatlogic Bot 5366b4681b CRM-V1
2025-12-11 07:55:09 +00:00

29 lines
735 B
PHP

<?php
session_start();
require_once __DIR__ . '/db/config.php';
if (!isset($_GET['id']) || empty($_GET['id'])) {
$_SESSION['error_message'] = 'Invalid activity ID.';
header('Location: index.php');
exit;
}
$activity_id = $_GET['id'];
try {
$pdo = db();
$stmt = $pdo->prepare("DELETE FROM activities WHERE ActivityID = ?");
$stmt->execute([$activity_id]);
if ($stmt->rowCount() > 0) {
$_SESSION['success_message'] = 'Activity deleted successfully!';
} else {
$_SESSION['error_message'] = 'Activity not found or already deleted.';
}
} catch (PDOException $e) {
$_SESSION['error_message'] = 'Error deleting activity: ' . $e->getMessage();
}
header('Location: index.php');
exit;