hi, i have been trying to send data from a input text field in flash to a PHP script, and save the data to a text document. I don’t get any error messages from flash when i run the file but the PHP script don’t receive the data.
I hope someone will bee able to help me solve the problem
<?php
//Capture data from $_POST array
$myData = $_POST['myData'];
//Make one big string in a format Flash understand
echo ($myData);
//$toSave ="Title=$title&Comments=$comments&Image=.$image";
//Open a file in write mode
$fp = fopen("myData.txt", "w");
fwrite($fp, $myData);
fclose($fp);
echo("kommer der noget igennem");
?>
and from flash
var nyTitle= Title.text;
var nyComments= Comments.text;
var nyImage= Image.text;
submit.addEventListener("mouseDown", sendData)
function sendData(evt:Event):void{
if(Title.text!="" && Comments.text !="" && Image.text!=""){
var data:String ="Title=" + nyTitle + "&Comments=" + nyComments + "&Image.text=" + nyImage;
var variables:URLVariables = new URLVariables(data);
var myData:URLRequest = new URLRequest("http://platform6000.dk/gemme.php");
myData.method = URLRequestMethod.POST;
myData.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
try{
loader.load(myData);
loader.addEventListener(Event.COMPLETE, dataOnLoad);
trace(variables);
}
catch (error:Error)
{
trace('Unable to load requested document.');
}
} else {
status_txt.text = "All fields are mandatory"
}
}
function dataOnLoad(e:Event){
trace("ok");
status_txt.text=("ok");
}