A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [RESOLVED] Some PHP troubles....

  1. #1
    Senior Member Zoranan's Avatar
    Join Date
    May 2008
    Posts
    126

    resolved [RESOLVED] Some PHP troubles....

    I've wanted to make a Flash chat room for a long time, but never knew how. I just learned the basics of php, and can create simple php scripts.

    I have successfully made a script that writes to a .txt file. So I took my flash document, and made the input text field define what the php script ads to the .txt file so that flash can load the .txt file into the message window using loadVars.

    All of this works fine, exept the way I have to call the php script due to my lack of php scripting knowledge.

    when the enter key is pressed, the following function is called...

    function send(){
    message = element ("input").text;
    getURL ("http://localhost/file_write.php", "_blank", "POST");
    element ("input").text = "";}


    so, as you could see this will open the php script in a new window/tab, php correctly receives the "message" variable, and properly writes the .txt file.

    But haveing new windows/tabs opened up all of the time is not fun, and I can't for the life of me figure out how to run this script without opening new windows/tabs.

    my php script is...

    <?php

    $message = $_POST['message'];

    $file_name = "write.txt";
    if (file_exists($file_name)){

    $handle = fopen($file_name, 'a+');

    if (!$handle){
    die ("could't open file <i>$file_name</i>");
    }

    fwrite($handle,"\r\n$message");
    echo "success writing to file";
    }

    else {
    echo "file doesn't exist";
    }

    fclose($handle);
    ?>


    If anyone knows a better way to call php other than getURL ("http://localhost/file_write.php", "_blank", "POST"); please reply

    Thanks...

  2. #2
    Member
    Join Date
    Nov 2007
    Location
    Brazil
    Posts
    47
    try loadVariables:

    root.loadVariables("http://localhost/file_write.php", "POST");
    []'s
    leocavalcante.com

  3. #3
    Senior Member Zoranan's Avatar
    Join Date
    May 2008
    Posts
    126

    WOW! Thanks!

    I've tried that before, but without the "root". It works great now! All I have left to do is to add a user name and put it on the web

    Thanks again...

  4. #4
    Senior Member Zoranan's Avatar
    Join Date
    May 2008
    Posts
    126
    Hmmm, having trouble finding a good place to upload this... I cant find a free php enabled web server...

    Zoranan

  5. #5
    Member
    Join Date
    Nov 2007
    Location
    Brazil
    Posts
    47
    I use www.110mb.com []
    []'s
    leocavalcante.com

  6. #6
    Senior Member Zoranan's Avatar
    Join Date
    May 2008
    Posts
    126
    Well, I took a look, and they specifically said, NO CHAT ROOMS. Worth a shot, but no good...

    Zoranan
    Last edited by Zoranan; 06-10-2008 at 01:04 PM.

  7. #7
    Member
    Join Date
    Nov 2007
    Location
    Brazil
    Posts
    47
    Oh sorry :/
    []'s
    leocavalcante.com

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