A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: PHP...i don't get it!

  1. #1

    PHP...i don't get it!

    i can't figure out how to write that "post.php"
    i've made a trace to check if vars were send and yes, those are send. but now how can i get back those values within PHP ?

    i've read many things ( stickies from musicman etc...) but... i don't gettit .... could someone help me on that?


    on (release) {
    myvars = new LoadVars();
    myvars.titre = _level0.titrenew;
    myvars.texte = _level0.textenew;
    //
    myvars.send("post.php", 0);
    //
    }


    thx in advance

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    try,

    Code:
    on (release) {
        myVars = new LoadVars();
        myVars.titre = _level0.titrenew;
        myVars.texte = _level0.textenew;
        myVars.send("http://www.yourserver.com/post.php", "_blank", "POST");
    }
    this should open a new browser window containing the page post.php

    a simple script to test if the variables are arriving as expected could be,

    PHP Code:
    <?php

    while (list($index$value) = each($_POST)) {
        echo 
    "<p>$index ---- $value</p>";
    }

    ?>
    in your post.php script. this should write out the variables that are recieved.

  3. #3
    Ok perfect !

    thanks a lot... now the last question; how to avoid the "open window" and just give the var to the php file?

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    you could use sendAndLoad, this allows you to send variables to the PHP script and get a response (maybe just to say the script ran okay) back to flash,

    Code:
    myVarsSend = new LoadVars();
    myVarsLoad = new LoadVars();
    
    myVarsSend.titre = _level0.titrenew;
    myVarsSend.texte = _level0.textenew;
    
    myVarsLoad.onLoad = function() {
        // got a response from PHP
    }
    myVarsSend.sendAndLoad("http://www.yourserver.com/post.php", myVarsLoad, "POST");
    any output from the PHP script, the stuff echoed to the page in the form of a string of urlencoded variables,

    eg

    echo "&output=okay&";

    will be returned to the myVarsLoad object, the onLoad event triggers when the loading has finished.

  5. #5
    millions of thank you!

    you made 2 people happy ... me & my client

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center