beginTransaction(); // Delete associated steps first $stmtSteps = $pdo->prepare("DELETE FROM process_steps WHERE process_id = :id"); $stmtSteps->bindParam(':id', $id, PDO::PARAM_INT); $stmtSteps->execute(); // Then delete the process $stmtProcess = $pdo->prepare("DELETE FROM processes WHERE id = :id"); $stmtProcess->bindParam(':id', $id, PDO::PARAM_INT); if ($stmtProcess->execute()) { $pdo->commit(); header('Location: index.php?success=processdeleted'); exit(); } else { $pdo->rollBack(); header('Location: index.php?error=deletionfailed'); exit(); } } catch (PDOException $e) { $pdo->rollBack(); error_log("DB Error: " . $e->getMessage()); header('Location: index.php?error=dberror'); exit(); } } else { header('Location: index.php?error=invalidrequest'); exit(); } ?>