Stefan118
09-02-2012, 08:47 PM
I would like to have a counter that writes in a file how often a banner is clicked.
The script below works, but how do I add to this that once the banner is clicked this link in a (new) window opens up?
I've tried everything, but nothing seems to work.
I tried also to put ANOTHER a href with the link that needs to open in the new window after the existing a href.
Then the link works, but the counter doesn't anymore!
Please help???
<?php
if(!file_exists('counter.txt')){
file_put_contents('counter.txt', '0');
}
if($_GET['click'] == 'yes'){
file_put_contents('counter.txt', ((int) file_get_contents('counter.txt')) + 1);
header('Location: ' . $_SERVER['SCRIPT_NAME']);
die;
}
?>
<head>
<title>counter example</title>
</head>
<body>
<a href="?click=yes"><img src="banner.jpg">
</a>
</body>
</html>
The script below works, but how do I add to this that once the banner is clicked this link in a (new) window opens up?
I've tried everything, but nothing seems to work.
I tried also to put ANOTHER a href with the link that needs to open in the new window after the existing a href.
Then the link works, but the counter doesn't anymore!
Please help???
<?php
if(!file_exists('counter.txt')){
file_put_contents('counter.txt', '0');
}
if($_GET['click'] == 'yes'){
file_put_contents('counter.txt', ((int) file_get_contents('counter.txt')) + 1);
header('Location: ' . $_SERVER['SCRIPT_NAME']);
die;
}
?>
<head>
<title>counter example</title>
</head>
<body>
<a href="?click=yes"><img src="banner.jpg">
</a>
</body>
</html>