# POSTing vars when calling PHP via XML.onLoad

**URL:** <https://forum.kirupa.com/t/posting-vars-when-calling-php-via-xml-onload/260614>\
**Category:** programming\
**Created:** [May 17, 2008, 3:39pm UTC](https://forum.kirupa.com/t/posting-vars-when-calling-php-via-xml-onload/260614 "2008-05-17T15:39:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nburlington](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nburlington/32/1365_2.png) [@nburlington](https://forum.kirupa.com/u/nburlington)\
**Post date:** [May 17, 2008, 3:39pm UTC](https://forum.kirupa.com/t/posting-vars-when-calling-php-via-xml-onload/260614/1 "2008-05-17T15:39:35Z")

</div>

In Flash, I’m trying to pass some flash vars to a .php script that’s running an SQL query.

The .php echoes xml that I’m parsing in flash.

Here’s my problem:

```auto

var postMe:String = "I want to get posted to php so it can use me in the SQL query";

var sqlQuery = new XML();
sqlQuery.ignoreWhite = true;
sqlQuery.onLoad = loadSQL;
sqlQuery.load("http://www.mySite.com/my.php");

function loadSQL(){
}

```

As is, in my .php I can’t use:  
$var = $\_POST[“postMe”];

How do I get the postMe var into the .php and still use the XML.onLoad to grab the data returned from .php?

or

How do I get my cake and eat it too?

---

<div class="post-metadata">

**Author:** ![toltec7](https://avatars.discourse-cdn.com/v4/letter/t/f17d59/32.png) [@toltec7](https://forum.kirupa.com/u/toltec7)\
**Post date:** [May 17, 2008, 4:16pm UTC](https://forum.kirupa.com/t/posting-vars-when-calling-php-via-xml-onload/260614/2 "2008-05-17T16:16:07Z")

</div>

var postMe:String = “I want to get posted to php so it can use me in the SQL query”;

var sqlQuery = new LoadVars();  
var sqlReceiver = new XML();

sqlReceiver.ignoreWhite = true;  
sqlReceiver.onLoad = loadSQL;

sqlQuery.postMe = postMe;  
sqlQuery.sendAndLoad(“[http://www.mySite.com/my.php](http://www.mySite.com/my.php)”, sqlReceiver, “POST”);

function loadSQL(){  
}

[quote=nburlington;2327532]In Flash, I’m trying to pass some flash vars to a .php script that’s running an SQL query.

The .php echoes xml that I’m parsing in flash.

Here’s my problem:

```auto

var postMe:String = "I want to get posted to php so it can use me in the SQL query";

var sqlQuery = new XML();
sqlQuery.ignoreWhite = true;
sqlQuery.onLoad = loadSQL;
sqlQuery.load("http://www.mySite.com/my.php");

function loadSQL(){
}

```

As is, in my .php I can’t use:  
$var = $\_POST[“postMe”];

How do I get the postMe var into the .php and still use the XML.onLoad to grab the data returned from .php?

or

How do I get my cake and eat it too?[/quote]

---

<div class="post-metadata">

**Author:** ![djheru](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/djheru/32/3190_2.png) [@djheru](https://forum.kirupa.com/u/djheru)\
**Post date:** [May 18, 2008, 3:10pm UTC](https://forum.kirupa.com/t/posting-vars-when-calling-php-via-xml-onload/260614/3 "2008-05-18T15:10:16Z")

</div>

What toltec7 isdoing is taking the XML object that you created, creating a new property for it and assigning the value of postMe to it.
