I need to track a button every time someone clicks on it. I created a file "out.php" to send me an email and redirect to a link outside my page. This code redirects but the mail doesn't send.
<div class="buyprod">
<a target="_blank" href="http://xxx.com/out.php?url=<?php echo urlencode($this->product['from'])?>">
<img src="http://xxx.com/buybtn.jpg" alt="buy"/>
</a>
</div>
out.php
<?php
$url = urldecode($_GET['url']);
header("Location: ".$url);
$message = "Someone clicked buy: ";
$link = $this->product['from'];
mail('xxx@xxx.com', '@Buy', $message.$link);
exit;
Anyone knows what's wrong with this code? Thanks in advance!