# Sending variables from Flash to php - wont work for some reason!

**URL:** <https://forum.kirupa.com/t/sending-variables-from-flash-to-php-wont-work-for-some-reason/185392>\
**Category:** Uncategorized\
**Created:** [April 12, 2006, 11:32pm UTC](https://forum.kirupa.com/t/sending-variables-from-flash-to-php-wont-work-for-some-reason/185392 "2006-04-12T23:32:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcurrid](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pcurrid](https://forum.kirupa.com/u/pcurrid)\
**Post date:** [April 12, 2006, 11:32pm UTC](https://forum.kirupa.com/t/sending-variables-from-flash-to-php-wont-work-for-some-reason/185392/1 "2006-04-12T23:32:52Z")

</div>

Hi,  
for some reason, I cant get my variables in Flash8 sent to a php file.  
I have a local server set up on my PC, so maybe its a security issue???  
I tried using getURL and it seemed to send as I could see the variables in the url but I could not echo them in the php file.

Now I’m trying the loadVariablesNum method  
I have the following variables attached to input boxes:  
name\_var, age\_var, address\_var

I also have a button called submit\_btn

and the very simple piece of actionscript:

submit\_btn.onPress = function () {

loadVariablesNum(“pleasework.php”,0,“POST”);  
}

here is the relevant code on the pleasework.php  
\<?php  
$age = $\_POST[‘name\_var’];  
$name = $\_POST[‘age\_var’];  
$address = $\_POST[‘address\_var’];

echo $age;  
echo $name;  
echo $address;  
echo $test;  
?\>

---

<div class="post-metadata">

**Author:** ![Liger](https://avatars.discourse-cdn.com/v4/letter/l/839c29/32.png) [@Liger](https://forum.kirupa.com/u/Liger)\
**Post date:** [April 13, 2006, 7:12am UTC](https://forum.kirupa.com/t/sending-variables-from-flash-to-php-wont-work-for-some-reason/185392/2 "2006-04-13T07:12:50Z")

</div>

Use $\_GET instead of $\_POST

> [@pcurrid](#):
>
> Hi,  
> for some reason, I cant get my variables in Flash8 sent to a php file.  
> I have a local server set up on my PC, so maybe its a security issue???  
> I tried using getURL and it seemed to send as I could see the variables in the url but I could not echo them in the php file.
> 
> Now I’m trying the loadVariablesNum method  
> I have the following variables attached to input boxes:  
> name\_var, age\_var, address\_var
> 
> I also have a button called submit\_btn
> 
> and the very simple piece of actionscript:  
> [AS]  
> submit\_btn.onPress = function () {
> 
> loadVariablesNum(“pleasework.php”,0,“POST”);  
> }  
> [/AS]  
> here is the relevant code on the pleasework.php
> 
> ```php
> 
> <?php
> $age = $_POST['name_var'];
> $name = $_POST['age_var'];
> $address = $_POST['address_var'];
> 
> echo $age;
> echo $name;
> echo $address;
> echo $test;
> ?>
> 
> ```

---

<div class="post-metadata">

**Author:** ![pcurrid](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pcurrid](https://forum.kirupa.com/u/pcurrid)\
**Post date:** [April 13, 2006, 10:32am UTC](https://forum.kirupa.com/t/sending-variables-from-flash-to-php-wont-work-for-some-reason/185392/3 "2006-04-13T10:32:58Z")

</div>

tried that too,  
and got nothing…very strange

---

<div class="post-metadata">

**Author:** ![lolomedia](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@lolomedia](https://forum.kirupa.com/u/lolomedia)\
**Post date:** [April 13, 2006, 1:41pm UTC](https://forum.kirupa.com/t/sending-variables-from-flash-to-php-wont-work-for-some-reason/185392/4 "2006-04-13T13:41:03Z")

</div>

well, how do you have assigned your variables to load?

example:?  
ActionScript Code:  
[FONT=Courier New][LEFT]submit\_btn.onPress = function COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]  
age\_var = age.[COLOR=#0000FF]text[/COLOR];  
name\_var = [COLOR=#0000FF]name[/COLOR].[COLOR=#0000FF]text[/COLOR];  
address\_var = address.[COLOR=#0000FF]text[/COLOR];  
[COLOR=#0000FF]loadVariables[/COLOR]COLOR=#000000[/COLOR];  
[/LEFT]  
[/FONT]

i didn’t see below you assigned your variables… how do you have them assigned? :pir:

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 13, 2006, 1:46pm UTC](https://forum.kirupa.com/t/sending-variables-from-flash-to-php-wont-work-for-some-reason/185392/5 "2006-04-13T13:46:13Z")

</div>

try this instead:

```auto
submit_btn.onPress = function () {
   var please:LoadVars = new LoadVars();
   please.name_var;
   please.age_var;
   please.address_var;
   please.sendAndLoad("pleasework.php",0,"POST");
}

```

```php
<?php 
   $age = $_POST['name_var']; 
   $name = $_POST['age_var']; 
   $address = $_POST['address_var']; 

   echo $age; 
   echo $name; 
   echo $address; 
?>

```

---

<div class="post-metadata">

**Author:** ![pcurrid](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pcurrid](https://forum.kirupa.com/u/pcurrid)\
**Post date:** [April 13, 2006, 4:47pm UTC](https://forum.kirupa.com/t/sending-variables-from-flash-to-php-wont-work-for-some-reason/185392/6 "2006-04-13T16:47:41Z")

</div>

I tried the sendAndLoad method,  
but am still getting nothing when I go to view the php view in my browser.

all files are stored on the same location on my local apache server ([http://localhost)](http://localhost%29). I tried using both the swf and the html containing the swf but still got nothing. Would it have anything to do with the way I am publishing the swf?  
Thanks for the help by the way!

---

<div class="post-metadata">

**Author:** ![pcurrid](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pcurrid](https://forum.kirupa.com/u/pcurrid)\
**Post date:** [April 13, 2006, 6:04pm UTC](https://forum.kirupa.com/t/sending-variables-from-flash-to-php-wont-work-for-some-reason/185392/7 "2006-04-13T18:04:01Z")

</div>

think I have managed to get it working.

register\_globals was set to On in my php.ini file.  
also, I was only entering text through the swf file on its own,  
as opposed to the html file that contained the embedded swf file,  
it seemed to work when I did the latter, I dont know if thats expected or not?!
