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:
Actionscript Code:
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:
Actionscript Code:
<?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:
Actionscript Code:
on (release)
{
amount.text=5;
form1= new LoadVars();
form1.amount= this.amount.text;
form1.sendAndLoad("http://mywebpage.com/test.php",amount,"POST");
}
and
Actionscript Code:
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:
Actionscript Code:
on (release)
{
amount.text=5;
form1= new LoadVars();
form1.amount= amount.text;
form1.sendAndLoad("http://mywebpage.com/test.php",form1,"POST");
}
and still nothing. Then I put the as right onto the button like this:
Actionscript Code:
var sendLV:LoadVars=new LoadVars();
var receiveLV:LoadVars=new LoadVars();
yourbutton.onRelease=function(){
amount.text=5;
sendLV.amount= amount.text;
sendLV.sendAndLoad("http://mywebpage.com/test.php",receiveLV,"POST");
}
receiveLV.onData=function(src){
trace(src);
}
Not working either.
In my php file I even tried the GET instead of the POST and it still turns up nothing.
Actionscript Code:
<?php
$form_inp= $_GET['monto'];
if ($form_inp=='')
{
print "Nothing inputted <br>";
}
else
{
print "You have inputted: $form_inp";
}
?>
Then I changed my php to something simpler:
Actionscript Code:
<?php
$amount= $_POST['amount'];
echo "You have:" . $amount;
?>
And, guess what? That's right.... Nothing!
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.