# Refresh PHP file with Flash method Post

**URL:** <https://forum.kirupa.com/t/refresh-php-file-with-flash-method-post/304945>\
**Category:** programming\
**Created:** [February 17, 2010, 12:25am UTC](https://forum.kirupa.com/t/refresh-php-file-with-flash-method-post/304945 "2010-02-17T00:25:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skot00mc](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@skot00mc](https://forum.kirupa.com/u/skot00mc)\
**Post date:** [February 17, 2010, 12:25am UTC](https://forum.kirupa.com/t/refresh-php-file-with-flash-method-post/304945/1 "2010-02-17T00:25:04Z")

</div>

I have a .swf embedded into my php file. I want to click a button in the .swf that Posts a variable, then reloads the php file with the Post method.

As of right now, when I click the .swf button, the browser status bar seems to load something, but the page itself does not refresh.

Is this possible to do?

Here is my PHP code:

```auto

    if(isset($_POST) && $_POST == 'submitLocation') {
        $submitLocation = $_POST['submitLocation'];
        echo "Location = ". $_POST['submitLocation'];
    }

```

Here is my Flash code:

```auto
function postToPHP () {    
    var request:URLRequest = new URLRequest ("http://localhost/_myprofile.php");
    var loader:URLLoader = new URLLoader (request);
    var vars:URLVariables = new URLVariables();                                
    
    // add the variables to our URLVariables
    vars.myLocation = myLocation;
    vars.action = "submitLocation";
    // send data via post
    request.method = URLRequestMethod.POST;
    request.data = vars;
                    
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, onComplete);
    loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

    loader.load(new URLRequest(request+'?r='+String(Math.random()*9999)));
    
            
    function onComplete (event:Event):void{
        vars.myLocation = myLocation;
        trace(loader.data.status);
        //navigateToURL(new URLRequest(request+"?submitLocation="+vars.myLocation), "_self");
    }
    
    function ioErrorHandler(event:IOErrorEvent):void {
        trace("ioErrorHandler: " + event.text);
    }

```
