import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequestMethod;
import flash.events.Event;
gonder_btn.addEventListener(MouseEvent.CLICK, sendData)
function sendData(event:MouseEvent):void
{
var urlreq:URLRequest = new URLRequest ("mydomain/dzak/gonder.php");
urlreq.method = URLRequestMethod.POST;
var urlvars:URLVariables = new URLVariables();
urlvars.isim = isim_txt.text;
urlvars.konu = konu_txt.text;
urlvars.masa = masa_txt.text;
urlvars.personel = personel_txt.text;
urlvars.mesaj = mesaj_txt.text;
urlreq.data = urlvars;
var loader:URLLoader = new URLLoader (urlreq);
loader.addEventListener(Event.COMPLETE, completed);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(urlreq);
}
有我的PHP代码。我用过PDO (gonder.php)
<?php
// database connection
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
$isim = @$_POST["isim"];
$konu = @$_POST["konu"];
$masano = @$_POST["masa"];
$personel = @$_POST["personel"];
$mesaj = @$_POST["mesaj"];
// query
if($_POST){
$sql = "INSERT INTO sikayet (adsoyad,masano,konu,mesaj,personel) VALUES (:isim,:masano,:konu,:mesaj,:personel)";
$q = $conn->prepare($sql);
$q->execute(array(':adsoyad'=>$adsoyad,
':masano'=>$masano,
':konu'=>$konu,
':mesaj'=>$mesaj,
':personel'=>$personel));
}
?>
当我执行fla时,我遇到了一些错误:
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables()
at flash.net::URLLoader/onComplete()
答案 0 :(得分:0)
您正在使用相对路径而不是绝对路径。 Flash播放器需要服务器端(PHP)代码调用的绝对路径,该代码调用部署在正在运行的服务器中。
您可以设置可配置的绝对路径,也可以在AS3代码中进行硬编码。确保在测试期间,您的PHP Web服务器正在使用您的PHP代码运行编码。
它肯定会奏效。
Current Value: "mydomain/dzak/gonder.php"
Expected Value: "http://www.mydomain/dzak/gonder.php"
尝试这样。