# SendAndLoad (php/flash)

**URL:** https://forum.kirupa.com/t/sendandload-php-flash/183630
**Category:** programming
**Created:** [March 28, 2006, 10:44pm UTC](https://forum.kirupa.com/t/sendandload-php-flash/183630 "2006-03-28T22:44:46Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![yonta](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@yonta](https://forum.kirupa.com/u/yonta)
#### Post date: [March 28, 2006, 10:44pm UTC](https://forum.kirupa.com/t/sendandload-php-flash/183630/1 "2006-03-28T22:44:46Z")

</div>

Hi 🙂

I can’t get this right ☹  
Currently i’m sending a variable through get method from a php file to a swf file embedded in the php file. That is working:)  
Then i want in flash to catch that variable and send it to another php file through post, and receive some info returned from the mysql db back in flash. I don’t think the php is the problem because the output is right.

I would really appreciate some help. I’ve read several tutorials but this isn’t working.

So here’s the actionscript:

```auto
function loadPostCard(id) {
    // Declare LoadVars object
    foto_ptl = new MovieClipLoader();
    var objEnvia:LoadVars = new LoadVars();
    objEnvia.postid=id;
    var objRecebe:LoadVars = new LoadVars();
    // when values are loaded
    objRecebe.onLoad = function(ok):Void {
        if (ok) {
            // display variables text; in frame continue
            txtPostal.htmlText = this["texto"+0];
            txtData.htmlText = this["data"+0];
            txtSender.htmlText = this["sender"+0];
            imgFile = this["foto"+0];
            foto_ptl.loadClip("images/banners/pt/"+imgFile, foto_postal);
        }
    };
    objEnvia.sendAndLoad("postcard_fl.php", objRecebe, "POST");
    
}

if (id != undefined) {
    gotoAndStop("continue");
    function() {
        loadPostCard(id);
    }
}

```

---

<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: [March 28, 2006, 10:46pm UTC](https://forum.kirupa.com/t/sendandload-php-flash/183630/2 "2006-03-28T22:46:10Z")

</div>

> Then i want in flash to catch that variable and send it to another php file through post, and receive some info returned from the mysql db back in flash. I don’t think the php is the problem because the output is right.

I have read this six times now, and it still isn’t clicking in… i need a coffee.

---

<div class="post-metadata">

### Author: ![yonta](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@yonta](https://forum.kirupa.com/u/yonta)
#### Post date: [March 28, 2006, 11:01pm UTC](https://forum.kirupa.com/t/sendandload-php-flash/183630/3 "2006-03-28T23:01:40Z")

</div>

> [@Defective](#):
>
> I have read this six times now, and it still isn’t clicking in… i need a coffee.

Ok. Sorry. English isn’t my mother language.

I’m building a site that was supposed to be done in php, but it suddenly changed to flash so i’m learning in a real haste. The site (an hotel), among other stuff, allows the sending of postcards (a photo with a message). The mail that is sent is something like this “X has sent you an email. Click here to view it”, the link is something like index.php?id=123. In index.php if a query variable is defined it’s sent to the embedded swf file.

In the actionscript i detect if an id variable is defined and if it is, i send it (through sendandLoad) to postcard\_fl.php to get the postcard that is being requested from the database. Upon the loading of the data i simply want to display the text and the photo.

Hope that was better 🙂

---

<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: [March 28, 2006, 11:05pm UTC](https://forum.kirupa.com/t/sendandload-php-flash/183630/4 "2006-03-28T23:05:15Z")

</div>

Much better. But i don’t know how to do that:D I remeber reading about it but i don’t really do it that often so i never remember. Usually people want to be able to type something like: "[http://www.somesite.com/someflash.swf&name=jimmy](http://www.somesite.com/someflash.swf&name=jimmy)"  
Then the flash comes up and says “Hi Jimmy!”. Kinda the same thing. I’ll do some Kirupa power searching for ya.🙂

---

<div class="post-metadata">

### Author: ![yonta](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@yonta](https://forum.kirupa.com/u/yonta)
#### Post date: [March 28, 2006, 11:10pm UTC](https://forum.kirupa.com/t/sendandload-php-flash/183630/5 "2006-03-28T23:10:55Z")

</div>

Ok 🙂 Thanx.

My php output string is this:

```auto
$var_url .= "&postid$n=".$row[0]."&sender$n=".$row[2]."&texto$n=".$row[4]."&data$n=".$row[5];

```

And here’s my php code (part):

```auto
if(isset($_POST['postid']) && is_numeric($_POST['postid'])){
    $postid = $_POST['postid'];
    $results = get_postcard($postid);
    $n = 0;
    foreach ($results as $row){
        $phoid = $row['phoid'];
        $photo = get_photo($phoid);
        $var_url .= "&postid$n=".$row[0]."&sender$n=".$row[2]."&texto$n=".$row[4]."&data$n=".$row[5];
        foreach ($photo as $pic){
            $var_url .= "&foto$n=".$pic[1];
        }
          $n++;
    }
    // add a value with the number of total items
    $var_url .= "&tamanho=$n";
    
    // code the string to utf-8 and print it
    print utf8_encode($var_url);

}

```

---

<div class="post-metadata">

### Author: ![yonta](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@yonta](https://forum.kirupa.com/u/yonta)
#### Post date: [March 29, 2006, 6:50pm UTC](https://forum.kirupa.com/t/sendandload-php-flash/183630/6 "2006-03-29T18:50:02Z")

</div>

Please please help. I really can’t get this to work ☹
