# \[PHP\] Hit Counter mod help needed

**URL:** https://forum.kirupa.com/t/php-hit-counter-mod-help-needed/156197
**Category:** programming
**Created:** [July 23, 2005, 5:29pm UTC](https://forum.kirupa.com/t/php-hit-counter-mod-help-needed/156197 "2005-07-23T17:29:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![diceman](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@diceman](https://forum.kirupa.com/u/diceman)
#### Post date: [July 23, 2005, 5:29pm UTC](https://forum.kirupa.com/t/php-hit-counter-mod-help-needed/156197/1 "2005-07-23T17:29:30Z")

</div>

[font=Arial]Hi,[/font]  
[font=Arial]Does anyone know how to modify the “\*\*Hit Counter \*\*in Flash using PHP” tutorial to use on multiple buttons in Flash for use as a click tracker?[/font]  
[font=Arial]I have a flash movie with nearly 100 buttons that I would like to track mouse clicks.[/font]

[font=Arial]This is what I have so far:[/font]  
[font=Arial]Filename is “counter.php” and the files will sit in the directory called “logs”.[/font]

[font=Arial]\<?php [/font]  
[font=Arial]$page = ($\_GET[‘page’]); [/font]  
[font=Arial]$logfile = “logs/” . $page . “.txt”; [/font]  
[font=Arial]if (! @$file = fopen($logfile,“r+”)) [/font]  
[font=Arial]{ [/font]  
[font=Arial]$count=“1”; [/font]  
[font=Arial]} [/font]  
[font=Arial]else { [/font]  
[font=Arial]$count = @fread($file, filesize($logfile)) or $count=0; [/font]  
[font=Arial]fclose($file); [/font]  
[font=Arial]$count++; [/font]  
[font=Arial]} [/font]  
[font=Arial]$count = file\_get\_contents($logfile); [/font]  
[font=Arial]$count = explode("=", $count); [/font]  
[font=Arial]$count[1] = $count[1]+1; [/font]  
[font=Arial]$file = fopen($logfile, “w+”); [/font]  
[font=Arial]fwrite($file, “count=”.$count[1]); [/font]  
[font=Arial]fclose($file); [/font]  
[font=Arial]print “count=”.$count[1]; [/font]  
[font=Arial]?\>[/font]

[font=Arial]And in Flash on each button I have this actionscript changing the end “button1”, “button2” etc:[/font]  
[font=Arial]on (release) { [/font]  
[font=Arial]this.loadVariables(“counter.php?page=button1”); [/font]  
[font=Arial]gotoAndPlay(18); [/font]  
[font=Arial]}[/font]

[color=black][font=Arial][size=2]The problem is that it writes the new text files if they don’t exist OK, but the count always remains at 1.[/size][/font][/color]

[font=Arial]Any help would be much appreciated. [/font]  
[font=Arial]Thanks in advance! [/font]

[font=Arial]diceman[/font]
