简体   繁体   中英

PHP variables to Flash via AS2 Returns Undefined

Really need another set of eyes on this, and thanks in advance! My php code:

<?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";
?>     

Sending the variables via a AS2 script to a swf contained in the header file. The AS2 code:

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;

End result keep getting undefined for the return. I do php but this AS2 stuff is new to me (got the code thru google), little better at AS3. Appreciate any suggestions, help, 2 days of looking for answers and I'm about done for. Thanks

use the sendAndLoad method to post data from flash to PHP and to load the response.

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');

file.php

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

Output in flash console : Hello from PHP

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM