A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: I need to send some variables from flash to php. I'm lost.

  1. #1
    Senior Member
    Join Date
    Apr 2004
    Posts
    231

    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.

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Moved to Scripting & Backend

    gparis

  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    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.
    Code:
    a       2
    b       0
    c       0
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center