计数器点击在PHP中的链接数量 [英] counter for number of clicks on links in php

查看:111
本文介绍了计数器点击在PHP中的链接数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现一个链接,点击计数器,将计算的链接...

I need to implement a links-click counter, that will count the number of clicks on the link...

现在我在做什么的,我是连接在href到redir.php,这将增加在DB的柜台,然后用头('位置:'); 我重定向到正确的URL。

Right now what i am doing is, i am linking the href to redir.php, which will increase the counter in DB and then using header('Location:'); I am redirecting it to the correct URL.

这工作,但它肯定不是最好的方法。在努力让我的code高效,我怎样才能使这个链接计数器更好? AJAX?

This works but it is certainly not the best approach. In an effort to make my code efficient, how can I make this link counter better? AJAX?

没有太大的EXP与阿贾克斯,所以我不知道该怎么办的阿贾克斯还是有其他更好的方法...

Not much exp with ajax so I wondering how to do in ajax or is there any other better method...

我不希望有人来写一个机器人脚本,这将使多个请求的redir.php扰乱了统计数据。

I do not want someone to write a bot script that would make multiple requests to the redir.php and mess up the stats.

推荐答案

您可以使用

  1. JavaScript来进行Ajax调用你的counter.php
  2. 添加一个Javascript code(如谷歌分析)每个页面上张贴的数据库
  3. 创建一个cron作业分析访问日志(如果算上在同一域中的链接,服务器)
  4. 添加一个PHP code对数据库进行更新时,每个页面生成。

不过,我认为第一个JavaScript方法是最好的。

But I think the first javascript method is the best one.

  1. 添加类的链接窥探
  2. 添加事件处理程序来创建一个AJAX后
  3. 创建一个简单的PHP脚本来更新数据库。

又名

这篇关于计数器点击在PHP中的链接数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆