# Php-flash newb

**URL:** <https://forum.kirupa.com/t/php-flash-newb/57537>\
**Category:** Uncategorized\
**Created:** [July 14, 2004, 1:36am UTC](https://forum.kirupa.com/t/php-flash-newb/57537 "2004-07-14T01:36:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glitch](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@Glitch](https://forum.kirupa.com/u/Glitch)\
**Post date:** [July 14, 2004, 1:36am UTC](https://forum.kirupa.com/t/php-flash-newb/57537/1 "2004-07-14T01:36:07Z")

</div>

Hello, i dont mean to be another one of those newbie pests asking another basic question that tends to bother the elders of the forum, but where other forums have let me down, im hoping kirupa can help 🙂 Heres my dilemma. I’ve been reading through tutorials, ive had other forums hit me with jargon i cant seem to comprehend, and im left alone, cold, and abused :hurt:. anyway. Simply enough all i want to do, is have an input box, a dynamic box, and a button. I type in the inputbox, i click the submit, i see in the dynamic. I understand the concept of load the variable into either a loadvariables, or loadVars, send that to my [http://localhost/php.php](http://localhost/php.php) file, use either $\_POST, $\_GET, etc. and have that print $variable here, back into flash using again, the loadVars, or loadVariables. Heres where i puzzle. In theory, i believe to know what to do and how to go about doing it, and when i go to work it out… no results. i downloade phpdev to setup the apache server … and the other things that came with it, and ive followed the tutorial on how to get a dynamic box to show a variable successfully, but when i branch off on my own im stuck. Heres what i got:

Actionscript:  
this.submit.onPress = function() {  
sender.loadVariables(“[http://localhost/tests/php.php](http://localhost/tests/php.php)”, “POST”);  
form.loadVariables(“[http://localhost/tests/php.php](http://localhost/tests/php.php)”, “POST”);  
};

sender is the movie clip that contains the inputbox  
form is the movie clip that contains the dynamic box.

php:  
\<?  
$text = $\_POST[“sendthis”];  
print “&read=$text”;  
?\>

sendthis is the variable name of the input box  
read is the variable name of the dynamic box

Again i dont mean to be a bother, or sound obnoxious… its been a long frusterating time of trial and error. Prethanks for any help.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2004, 1:41am UTC](https://forum.kirupa.com/t/php-flash-newb/57537/2 "2004-07-14T01:41:11Z")

</div>

loadVariables is pretty unpredictable. I’ve always had better luck using the loadVars object.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2004, 2:25am UTC](https://forum.kirupa.com/t/php-flash-newb/57537/3 "2004-07-14T02:25:07Z")

</div>

ive tried using loadVars prior to loadVariables because i know that it is easier to retrieve the variables. ex: variable.var1, variable.var2, etc. However im still unable to send my variable from flash to the php. Ive been able to retrieve data from php back to flash. ex:

\<?  
$var1 = “hello world”;  
print “&read=$var1”;  
?\>

using the method of loadVariables im able to retrieve no problem. Using loadVars however is another story. using loadVars i get "&read=hello%20World%20function()%20=onLoad, etc, a bunch of garbage. i believe that the %20 has something to do with HTML for i’ve seen it in browsers before. Im more focused right now on sending data to the php rather than getting it.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2004, 2:41am UTC](https://forum.kirupa.com/t/php-flash-newb/57537/4 "2004-07-14T02:41:23Z")

</div>

try doing it with POST instead of GET. The %20 is how a space is interpereted in a URL.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2004, 2:53am UTC](https://forum.kirupa.com/t/php-flash-newb/57537/5 "2004-07-14T02:53:30Z")

</div>

ok, skratch what i said before, im gonna try to make myself more clear, and simple in what im trying to accomplish.

All i have on the main timeline is a movieclip called submit  
Actionscript (on frame):

```php

this.submit.onPress = function() {
 sendme = new LoadVars();
 sendme = "One Small electronic data transfer for man, one giant headache for me";
 sendme.send("http://localhost/tests/php.php", "POST");
 trace(sendme);
};

```

and this is my php script:

```php

<?
$text=$_POST['sendme'];
print $text;
?>

```

all i want to happen is for my [http://localhost/tests/php.php](http://localhost/tests/php.php), to say what my loadVars is. Once this happens, ill go from their, but for now its still nonfunctional and i dont understand why.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2004, 2:58am UTC](https://forum.kirupa.com/t/php-flash-newb/57537/6 "2004-07-14T02:58:57Z")

</div>

Has anyone else had the problem where this works :

```auto

myLoadVars.send("something.php","newWindow");

```

but this does not :

```auto

myLoadVars.send("something.php");

```

???

It’s like the PHP only recieves the variables if the window is opened, otherwise it just doesn’t work?

-EG

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2004, 3:08am UTC](https://forum.kirupa.com/t/php-flash-newb/57537/7 "2004-07-14T03:08:41Z")

</div>

> [@Glitch](#):
>
> ok, skratch what i said before, im gonna try to make myself more clear, and simple in what im trying to accomplish.
> 
> All i have on the main timeline is a movieclip called submit  
> Actionscript (on frame):
> 
> ```php
> 
> this.submit.onPress = function() {
> sendme = new LoadVars();
> sendme = "One Small electronic data transfer for man, one giant headache for me";
> sendme.send("http://localhost/tests/php.php", "POST");
> trace(sendme);
> };
> 
> ```
> 
> and this is my php script:
> 
> ```php
> 
> <?
> $text=$_POST['sendme'];
> print $text;
> ?>
> 
> ```
> 
> all i want to happen is for my [http://localhost/tests/php.php](http://localhost/tests/php.php), to say what my loadVars is. Once this happens, ill go from their, but for now its still nonfunctional and i dont understand why.

```php

this.submit.onPress = function() {
 sendme = new LoadVars();
 sendme.quote = "One Small electronic data transfer for man, one giant headache for me";
tempsend = new LoadVars();
 tempsend.sendAndLoad("http://localhost/tests/php.php", sendme, POST);
 trace(sendme.quote);
};

```

```php

<?
$text=$_POST['quote'];
echo "$text";
?>

```

That should work if I’m not mistaken. You had a few errors in your code. First of all, loadVars is an object. It can store more than one value. For this reason, you can not set your loadVars to one specific string. You must use it as you would use a movieclip, and put your seperate variables inside of it. Second, you can’t send the loadvars from inside itself, you must create a new loadvars to send it (at least i’ve always had to to get it to work). Also, for some reason it doesn’t work if you put quotes around POST.

In the php, you are trying to echo the specific variable. So you want to use quote, not the name of the entire loadvars.

Hope this helped 🍺

Grandpa: Use sendAndLoad to solve that problem (as I did above but didn’t mention…) You probably wanted it to open in a new window though when i look back… Oh well, that should be easy enough for you to change 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2004, 3:32am UTC](https://forum.kirupa.com/t/php-flash-newb/57537/8 "2004-07-14T03:32:15Z")

</div>

Ok, thank you for the loadVars explanation. That makes more sence than my prior logic. Question is now, when i click my movie clip, my “php.php” which im running through the apache server on localhost, should display “One small electronic transfer for man, one giant headache for me” right? If so, its not doing it. It appears as if it is sending something for it occasionally triggers a firewall monitor which alerts me of programs accessing the internet. Progress… yet not perfection. Help is greatly appreciated though. Oh, one more thing, which i dont want to sound like a complete moron saying this so late… does it matter that im running win98? … everything seams functional i’m even being able to log into a mySQL database, so just wondering.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2004, 3:55am UTC](https://forum.kirupa.com/t/php-flash-newb/57537/9 "2004-07-14T03:55:47Z")

</div>

you might need to forward some ports or something, are you running php on your system? And do you have a web server installed? That’s not my strong suit though, sorry.

As I said earlier, to see the result, you need to change that code I posted a little bit so that it pops up a window. Or change the php to echo out stuff in a format that flash reads and then use sendAndLoad plus onLoad to echo it out in your flash movie.
