prepare("INSERT INTO links (slug, destination_url) VALUES (?, ?)"); $stmt->execute([$slug, $url]); header("Location: index.php"); exit; } // Fetch all links $stmt = $pdo->query("SELECT l.*, COUNT(s.id) as total_scans FROM links l LEFT JOIN scans s ON l.id = s.link_id GROUP BY l.id ORDER BY l.created_at DESC"); $links = $stmt->fetchAll(); ?>