<a href="http://www.example.com/banner.php?id=1"><img src.... /></a>
<?php
$file = fopen('data.txt', 'w');
fwrite($file, $_GET['id'] . '\n');
fclose($file);
?>
$file = fopen('data.txt', 'a');
<?php file_put_contents('log.txt', $_GET['id']. "\n", FILE_APPEND); ?>