Joe Slater
Joe Slater

Reputation: 2473

how to communicate between php and flash

I have a php file which looks like this.

<?php
session_start();

$_SESSION['username']= ________;//Get data from swf file
$_SESSION['password']=_________;//Get data from swf file
?>

<!------EMBEDDING SWF FILE--->
<html>
    <body>
        <div id="flashContent">
            <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="1024" height="600" id="indexFLA" align="middle">
                <param name="movie" value="indexFLA.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#ffffff" />
                <param name="play" value="true" />
                <param name="loop" value="true" />
                <param name="wmode" value="window" />
                <param name="scale" value="showall" />
                <param name="menu" value="true" />
                <param name="devicefont" value="false" />
                <param name="salign" value="" />
                <param name="allowScriptAccess" value="sameDomain" />
                    <a href="http://www.adobe.com/go/getflash">
                        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                    </a>
            </object>
        </div>
    </body>
</html>

Now I want to set the $_SESSION[] variables using the actionscript3 in the embedded flash file.

I know that you can use URLRequest("file.php") to communicate with external php but I am not sure how this will work to communicate with the php the swf file itself is in.

How would I do this?

Thanks

Upvotes: 1

Views: 5198

Answers (1)

MarcinWolny
MarcinWolny

Reputation: 1641

Your flash file is not in PHP :). You just embed the object in HTML code printed by PHP.

Now, as for communication between flash and PHP:

Basically: To pass a variables by loading a page (either with POST data being sent or proper content being printed out)

Also you NEVER should pass sensitive data, like user name and password, by simply using flashvars (aka. embedding it in HTML code like you asked) - equally well you can print in on the screen. It's completely insecure. You should pass encrypted data (or better: only a checksums) during code execution. NOT in a way that can be read by anyone who knows how to view source code of a webpage.

Upvotes: 2

Related Questions