-
I need to send some variables from flash to php. I'm lost.
I have a simple banner that has three choices. A, B, and C. When a user clicks on one of the choices...I just need a counter to make note of it...in some remote file. Php I would guess.
So the end result is that you could access the php file and see that choice A was clicked however many times, and choice B was clicked so many times, etc.
But I am not a Php guy and don't know what syntax to use to make this happen.
I would appreciate any help...Thanks.
-
Moved to Scripting & Backend
gparis
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|