29 Replies Latest reply: Sep 12, 2012 2:36 AM by Claudiu_Sararu RSS

    Passing variables from flash to php script - Not working!

    Arion03 Community Member

      Hey everyone. I was wondering if anyone could help me. I am using as2 to pass a variable from flash to my php and nothing is being passed! Here is the action script code that I put on my button:

       

      on (release)

      {

                amount.text=5;

                form1= new LoadVars();

                form1.amount= amount.text;

                form1.sendAndLoad("http://mywebpage.com/test.php",amount,"POST");

                }

       

      Now the amount of "5" is being inputted into a dynamic text field with the variable and instance name of amount  (which, in the future, will be hidden ). This is working fine when clicking on the button. What I am trying to do, without success, is to get this value of "5" to my test.php and have it echoed and it's just not happening . This is my php script:

       

      <?php

       

      $form_inp= $_POST['amount'];

      if ($form_inp==''")

      {

      print "Nothing inputted <br>";

      }

      else

      {

      print "You have inputted: $form_inp";

      }

      ?>

       

      I'm getting "Nothing inputted" everytime.

       

      I've already tried the different routes for the amount.text such as:

       

      on (release)

      {

        amount.text=5;

        form1= new LoadVars();

        form1.amount= this.amount.text;

        form1.sendAndLoad("http://mywebpage.com/test.php",amount,"POST");

        }

       

      and

       

      on (release)

      {

        amount.text=5;

        form1= new LoadVars();

        form1.amount= this._parent.amount.text;

        form1.sendAndLoad("http://mywebpage.com/test.php",amount,"POST");

        }

       

      etc.........

       

      I've also tried changing the variable name in the sendAndLoad function from amount to form1 like this:

       

      on (release)

      {

        amount.text=5;

        form1= new LoadVars();

        form1.amount= amount.text;

        form1.sendAndLoad("http://mywebpage.com/test.php",form1,"POST");

        }

       

      and still nothing.

       

      In my php file I even tried the GET instead of the POST and it still turns up nothing.

       

      <?php

       

      $form_inp= $_GET['monto'];

      if ($form_inp=='')

      {

      print "Nothing inputted <br>";

      }

      else

      {

      print "You have inputted: $form_inp";

      }

      ?>

       

      Extra info:  I have put the .swf file and the .php file on the same level in the same folder on my server just to be sure and the amount.text dynamic text field and the button are on the same level in the .swf file.

       

      Can anyone shed some light on my situation.......... pretty please? I am at wits end!

       

      Thank you soooo much.