Aca dejo en script...
Código PHP:
function getRealIP() {
if (!empty($_SERVER['HTTP_CLIENT_IP']))
return $_SERVER['HTTP_CLIENT_IP'];
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
return $_SERVER['HTTP_X_FORWARDED_FOR'];
return $_SERVER['REMOTE_ADDR'];
}
$id = $_GET['id'];
mysql_connect("host", "root", "pass") or die(mysql_error());
mysql_select_db("bnotte") or die(mysql_error());
$update = "UPDATE total_clicks SET clicks=(clicks + 1) WHERE id='$id'";
mysql_query($update) or die (mysql_error());
$ip = getRealIP();
$update = "INSERT INTO detalles_click (ip,clicks_ip,ad_id) VALUES ('$ip','1','$id') ON DUPLICATE KEY UPDATE clicks_ip = clicks_ip + 1";
mysql_query($update) or die (mysql_error());
$data = mysql_query("SELECT url FROM total_clicks WHERE id='$id'") or die(mysql_error());
$info = mysql_fetch_array($data);
//header("Location:" .$info['url']);
espero haber sido claro y gracias