Hi,
this is simple file-based counter:
Code:
<?
$choice = $_GET['choice'];
$fp = fopen("counter.txt", "r+");
flock($fp, LOCK_EX); // this might wait
$counts = Array();
while($line = fgets($fp))
{ ereg("(.*) ([0-9]*)", $line, $found);
$what = $found[1];
$count = $found[2];
if($what == $choice)
$count++;
$counts[$what] = $count;
}
fseek($fp, 0, SEEK_SET);
foreach($counts as $what => $count)
fputs($fp, "$what $count\n");
fclose($fp);
foreach($counts as $what => $count)
print "$what $count\n";
?>
the idea is that flash will request
Code:
counter.php?choice=a
The counter.txt file must exist on the server and list available choices, i.e.
The script will only count these (some fun guy sending choice "d" would not add that to the list) and then send new counts back.
If you use AS2, you should probably change the last two lines to send variables
Musicman