0) { $stmt = $pdo->prepare("SELECT url, status FROM websites WHERE id = ?"); $stmt->execute([$id]); $web = $stmt->fetch(); if ($web && $web['status'] === 'normal') { // Increment click count $update = $pdo->prepare("UPDATE websites SET click_count = click_count + 1 WHERE id = ?"); $update->execute([$id]); // Redirect header("Location: " . $web['url']); exit; } else if ($web) { // If not normal, shouldn't be called directly since JS should catch it, // but just redirect back to index if it happens header("Location: index.php"); exit; } } // Fallback header("Location: index.php"); exit;