Skip to main content
pen_test
Participating Frequently
August 6, 2014
Question

How to echo a Flash variable in Php

  • August 6, 2014
  • 1 reply
  • 1686 views

Okays.Let me start off by saying,"i am a noob".With that said,just ignore my poor explanation.I ve' been struggling to figure out what it is that is missing in my incoherent AS2 codes. What i am trying to achieve is very simple yet,confusing as i am still very new to several statements in AS2. My code below is accepting input from user(s).Then sends entered input to a Php file...which in-turns prints the entry in a new window.(some kinda test i choose to do).

AS 2 code --->

stop();

      submit_btn.onRelease = function() {

    if (Age_txt.text != '') {


var send_lv:LoadVars = new LoadVars();

var receive_lv:LoadVars = new LoadVars();

   send_lv.numby =Age_txt.text;

  send_lv.sendAndLoad("goto.php", receive_lv, "POST");

     getURL("goto.php", "_blank", "POST");

    } else {

   error_box.text = 'Fill fields correctly';

  }

};

Php goes like -->  <goto.php>

<?PHP

$catch=$_POST['numby'];

$hollaback='your fake age is $catch';

if($_POST[numby]) {

echo $hollaback ;

  }else {

         echo "you have entered nothing"; } 

?>

PS: The getURL() in my line 8 is just my way of forcing 'goto.php' to tell me what it caught in it's memory. I do not wish to send the msg back to flash via error_box.

                                                                                                          THANKS ALOT PEOPLES!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 6, 2014
use:

stop();

var send_lv:LoadVars = new LoadVars();

var receive_lv:LoadVars = new LoadVars();

receive_lv.onData=function(src:String){

trace(src);  // or use a textfield to display those echos

}

      submit_btn.onRelease = function() {

trace("sending "+Age_txt.text);  // for debugging

    if (Age_txt.text != '') {



   send_lv.numby =Age_txt.text;

  send_lv.sendAndLoad("goto.php", receive_lv, "POST");

   //  getURL("goto.php", "_blank", "POST");

    } else {

   error_box.text = 'Fill fields correctly';

  }

};

Php goes like -->  <goto.php>

<?PHP

$catch=$_POST['numby'];

$hollaback='your fake age is $catch';

if($_POST[numby]) {

echo $hollaback ;

  }else {

         echo "you have entered nothing"; } 

?>

PS: The getURL() in my line 8 is just my way of forcing 'goto.php' to tell me what it caught in it's memory. I do not wish to send the msg back to flash via error_box.

                                                                                                           THANKS ALOT PEOPLES!

pen_test
pen_testAuthor
Participating Frequently
August 8, 2014

Not trying to be an asse but Php would never print a flash variable with just an ECHO statement especially when the variable would have to be returned to the flash dynamic textfield(error_box) name.

Apart from this, while i am not very sure IF i need the trace(), your code above is correct.And seriously, i am not lazy to try.. it is just not working.I d' suggest(if you have time) for you to do a test run on the above code.. you might u/stand my frustration. However,thanks a bunch..after-all, you r not being paid to help me

kglad
Community Expert
Community Expert
August 8, 2014

AGAIN:  trace(src);  // or use a textfield to display those echos