Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pagina html:
- <!-- pagina html -->
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
- <script>
- $(function(){
- var clickCount={};
- $("a").on("click", function(){
- clickCount[this.href] = clickCount[this.href] ? clickCount[this.href]+1 : 1;
- console.log(clickCount);
- return true;
- });
- window.onbeforeunload = function()
- {
- //alert("loaded");
- console.log(clickCount);
- $.post('conteggio.php', clickCount);
- }
- });
- </script>
- <body>
- <a href="http://jsfiddle.net/">link 1</a><br>
- <a href="http://www.google.com">link 2</a><br>
- <a href="http://www.google.it">link 3</a>
- </body>
- /******************* FINE ******************/
- Pagina conteggio.php
- <?php
- $archivio="";
- foreach($_POST as $chiave => $valore)
- {
- if (is_array($valore))
- {
- $archivio .= "$valore รจ un array\n";
- foreach ($valore as $k => $elem)
- {
- $archivio .= "[".$k."] => $elem\n";
- }
- }
- else $archivio .= $chiave." => ".$valore."\n";
- }
- file_put_contents("conta-cliccati.txt", $archivio, FILE_APPEND);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement