0

真的需要另一双眼睛,提前谢谢!我的PHP代码:

<?php 
header('Location: videorecord.html');
$hour = time() + 3600;
setcookie(UserName, $_POST['UserName'], $hour); 
$_COOKIE["UserName"];

mysql_connect("localhost", "XXX", "XXX") or die(mysql_error());
mysql_select_db("XXX") or die(mysql_error());
$insert = "INSERT INTO usercards (RecName, Message, RecEmail, EventTitle)
        VALUES 
('$_POST[RecName]', '$_POST[Message]', '$_POST[RecEmail]',   '$_POST[EventTitle]')";   
$add_member = mysql_query($insert);
$var1="recpt=".$_POST['RecName'];
echo "&lVar1=$var1";
?>     

通过 AS2 脚本将变量发送到包含在头文件中的 swf。AS2 代码:

lv = new LoadVars();
// define onLoad Callback
lv.onLoad = onLoadCallBack;
// send and load variables
lv.load("http://XXXXX.com/pages/process_card.php");

// onLoad Callback
function onLoadCallBack(success)
{
// if succes
if(success)
{
    // trace variables
   trace(this.lVar1);
     _global.lVar1 = this.lVar1;

}
else
{
    // loading failed
    trace("Loading Error!!");
}
}
//end getting the external data

var movieName:String = lVar1;

最终结果不断变得不确定以返回。我做 php,但这个 AS2 的东西对我来说是新的(通过谷歌得到代码),在 AS3 上稍微好一点。感谢任何建议,帮助,寻找答案的 2 天,我即将完成。谢谢

4

1 回答 1

0

使用sendAndLoad方法将数据从 flash 发布到 PHP 并加载响应。

var send_lv:LoadVars = new LoadVars();
var result_lv:LoadVars = new LoadVars();

result_lv.onLoad = function(success:Boolean):Void {
   trace('result_lv.phpvar=' + result_lv.phpvar);
}

send_lv.flashvar = 'Hello from flash';
send_lv.sendAndLoad('path/to/file.php',result_lv, 'POST');

文件.php

<?php
   $fashvar = $_POST['flashvar'];
   echo '&phpvar=Hello from PHP&';
?>

Flash 控制台中的输出:来自 PHP 的 Hello

于 2013-05-11T22:28:48.597 回答