Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variables from Flash to PHP

Status
Not open for further replies.

carmenMiranda

Programmer
May 22, 2003
47
GB
I have a problem when trying pass a variable (entered into an input textfield) from Flash to PHP. When the button is hit to activate the LoadVars object, the PHP script returns the error message:

Notice: Undefined index: years in /Users/phil/Sites/phpflash/campaign/calculation.php on line 2

Here's the Flash script:

var path:String = "
var dataOut:LoadVars = new LoadVars();

myBtn.onRelease = function() {
dataOut.years = years_txt.text;
dataOut.send (path + "calculation.php", "_blank");
//trace(years_txt.text);
};

And here's the PHP script (called 'calculation.php'):

<?php
$calculation = $_POST['years']*7;
echo $calculation;
?>

The trace function shows me that the value entered by the user is recognised and I've done all the usual checks (ie: checking the path names and instance names etc are all correct), but I'm still getting the Undefined index error.

Can anyone help?
 
try

dataOut.sendAndLoad (path + "calculation.php", dataOut,"POST");
 
Hi, thanks for taking the time to read my question and reply.

I don't know if this answer has worked or not - removing the parameter "_blank" means I can't see any result in a browser. How do I check if this change is now working?
 
dataout.onLoad = function(){
trace(this.calculation)
}

also altered the phpfile to

<?php
$calculation = $_POST['years']*7;
print "calculation=$calculation";
?

seems to work fine

 
This isn't really helping me - I can't get the dataout.onLoad function you've described to work and the print command in the php script doesn't seem to be doing anything. Is it possible for you to explain exactly what's going on here?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top