<?php

require_once '../includes/auth.php';

$db->beginTransaction();

try{

    $stmt = $db->prepare("
        DELETE FROM cds_group_members
        WHERE cds_group_id=?
    ");

    $stmt->execute([
        $_POST['group_id']
    ]);

    $stmt = $db->prepare("
        DELETE FROM cds_groups
        WHERE id=?
    ");

    $stmt->execute([
        $_POST['group_id']
    ]);

    $db->commit();

}catch(Exception $e){

    $db->rollBack();
}

header("Location: ../dashboard/cds_groups.php");