-
Senior Member
[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...
-
try loadVariables:
root.loadVariables("http://localhost/file_write.php", "POST");
-
Senior Member
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...
-
Senior Member
Hmmm, having trouble finding a good place to upload this... I cant find a free php enabled web server...
Zoranan
-
-
Senior Member
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.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|