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 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考