Jump to content


Photo

PHP/FLASH/sendAndLoad - PLEASE HELP!!!!


  • Please log in to reply
2 replies to this topic

#1 hack4lk

hack4lk
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 24 June 2006 - 07:26 PM

Hi everyone....I have spent the last day trying to figure this problem out but cannot find what it is....I cannot send vars to php...but I can receive them in flash as echos from php....I am using sendAndLoad to send the vars to php....here is the code.

::Flash::
var sendData:LoadVars = new LoadVars();
sendData.myVar1 = "11111";
sendData.myVar2 = "impact";
sendData.sendAndLoad("test2.php", sendData, "POST");

::PHP::
$myVar1 = $_POST['myVar1'];
$myVar2 = $_POST['myVar2'];
echo $myVar2;


Thanks for any advice in advance.

#2 yonta

yonta
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 24 June 2006 - 09:50 PM

Here's an example (actionscript function):

function loadwhatever(){
var objSend:LoadVars = new LoadVars();

/*Values to be sent (id) */
objSend.id = '1';

/*Send variable to php and load the variables*/
objSend.sendAndLoad(whatever.php+"?nocache=" + Math.random(), objSend, "POST");

/*When the results are loaded into flash - add this*/
objSend.onLoad = function(ok) {

//do something here
}
}

In my experience you should force flash to not cache the results. Otherwise when you're testing you won't see he changes you made to the code.

On the php side everything seems fine.
do it, do it right, do it right now

#3 hack4lk

hack4lk
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 25 June 2006 - 12:31 AM

Works great but I had to change the send string to:
objSend.sendAndLoad("whatever.php?nocache=" + Math.random(), objSend, "POST");




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users