<?php
include __DIR__ . '/../database/search_log_config.php';

$id = (int)$_GET['id'];

$stmt = $log_conn->prepare("
UPDATE sponsored_keywords 
SET click_count = click_count + 1 
WHERE id = ?
");
$stmt->bind_param("i", $id);
$stmt->execute();
$stmt->close();

$result = $log_conn->query("
SELECT redirect_url FROM sponsored_keywords WHERE id=$id
")->fetch_assoc();

header("Location: ".$result['redirect_url']);
exit;
?>