10 Replies Latest reply on Jul 17, 2011 6:24 PM by 冰儿

    How do I properly transfer data from my flash movie to a PHP file?


      Hello all,


      So, I've been scouring the internet for tutorials and forums (for 3 days now), and I've found quite a bit of information.  However, no matter what I do I can't seem to get data from my components to a PHP file on my server.  Ultimately, I am making a flash form that will submit the form data to the PHP script and make entries into a mySQL database.  Before I do that, though, I thought I'd first just try to see if I could get data processed in PHP.  So, I created a simple PHP file that simply displays the data on the screen, and I made a single-button flash movie that has some actionscript in it.  Here is the code for the PHP file:


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      $data = $_POST['firstName'];
      $goob = $_POST['lastName'];
      $ming = $_POST['age'];

      echo $data;
      echo $goob;
      echo $ming;
      echo "...and that's all I've got.";


      And here is the code for the actionscript I have in my button:


      on (click){
          var firstName:String = "Gus";
          var lastName:String = "Richardson";
          var age:Number = 92;
          getURL("path_to_my_php_file_goes_here", "_blank", "POST");


      I'd like to note that my actionscript is a direct copy/paste from the Adobe online reference for actionscript 2 (with a change to the php path, of course).


      I upload everything and visit the page with the flash button in it.  When I click the button, I am taken to the .php page as expected, but the only thing I get on my screen is "...and that's all I've got."


      firstName, lastName, and age never get processed.  Eventually, I'll be wanting to send data from form components.  But as a first step, I can't even get this working correctly.  Does anyone have any insight?  It would be greatly appreciated.  On a side note, I'm using Macromedia Flash 8 (I'd love to upgrade, but Adobe won't let me since it's part of a suite...and I don't want to upgrade the whole suite.  But that's another story...)


      Thanks so much!


      Ed K.