click counter in php using jquery

泄露秘密 提交于 2020-01-03 04:45:06
问题 I am new to JQuery and trying to create a counter which counts the number of clicks and updates the counter in the database by one. I have created a button, on click of that i am sending the counter's value to the database. and trying to get the updated count at my first page. my code is - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html xmlns=""> <head> <meta http-equiv="Content-Type"

Click counter when link is clicked PHP/JS

早过忘川 提交于 2019-12-18 09:47:10
问题 I have a little script here that counts clicks when link is clicked and stores it in .txt file, but it works fine when I have only "click=yes" under href. But I can't make it to track clicks when I have link to external site. Here is my code: <?php if(!file_exists('counter.txt')){ file_put_contents('counter.txt', '0'); } if($_GET['click'] == 'yes'){ file_put_contents('counter.txt', ((int) file_get_contents('counter.txt')) + 1); header('Location: ' . $_SERVER['SCRIPT_NAME']); die; } ?> <