I have a website that I would like to record on links clicked on each page. As an example, below is the code for my index.html page in which I attempt to record a link:
<a href="https://mystie.html/trackIndexPageLinks.php?token=1" role="button" tabindex="0">ADA</a>
Where "trackIndexPageLinks.php" is the name of my php file and "?token=1" is the php variable and value that I would like to record in my server.
Listed below is the php code that I use to store the value and pass it to my server:
<?php
$db_hostname = '???.?.?.?';
$db_database = 'mySiteDB';
$db_username = 'something';
$db_password = '';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if(!$db_server) die("Unable to connect to MySQL:".mysql_error());
mysql_select_db($db_database)
or die("Unable to select database: ".mysql_error());
echo @mysql_ping() ? 'true':'false';
$token = $_GET['token'];
//Create insert statement - inserts data into the database.
$sql = "INSERT INTO clickLog (linkClicked)
VALUES ('$token')";
//Error check to ensure SQL statement took.
if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}
//Close connection.
mysql_close();
?>
However, I get no recorded records. Any assistance on this would be greatly appreciated.