prepare('SELECT id FROM users WHERE role_id = ?'); $stmt->execute([$role_id]); if ($stmt->fetch()) { header("Location: roles.php?error=role_in_use"); exit; } // Delete the role $stmt = $pdo->prepare('DELETE FROM roles WHERE id = ?'); $stmt->execute([$role_id]); header("Location: roles.php?success=role_deleted"); exit; } catch (PDOException $e) { // In a real app, log this error. header("Location: roles.php?error=db_error"); exit; }