I need to track clickthroughs on links in a local mysql table. As it is the code I have does nothing but take you to the clicked link.
To keep it simple I have it set so that if you click on the link it takes you to the link rather than a different page.
<a href="trackit.php" onclick="recordClick();">Click this link, then check log.txt</a>
The record clicks page is basic just to see if it works:
<?php $visitor_ip = $_POST['visitor_ip']; $visitor_ip = $_GET['visitor_ip']; $url = $_GET['url']; $fpi = fopen("log.txt","w"); fwrite ($fpi,"successn"); fwrite ($fpi,"visitor_ip: $visitor_ip | url: $urln"); ?>
The idea is that you click on the link and it sends the ip address and some other info the the record.php page. Once I get it to pass the data to the record page I’ll set up the mysql and table.
Source: Ask PHP