dra11767 2015-01-23 03:26
浏览 80
已采纳

跟踪链接使用HTML和PHP单击我的网站

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.

  • 写回答

1条回答 默认 最新

  • dreamevil0002 2015-01-23 04:08
    关注

    You're much better off to sign up with google analytics and add snippets of javascript code they provide. They can give you complete detail as to who is linking to what on your page as well as what links they click as well as the order they click them in.

    Go to: http://www.google.com/analytics/

    All you need is a google account and if you don't have one, you can sign up for one. The whole thing is free.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 maixpy训练模型,模型训练好了以后,开发板通电会报错,不知道是什么问题
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容