Saving text entered in flash onto a txt or php

I’ve done a search on this forum for this but so far no luck concerning on how to do this the php way, only cookies…

Is there a way to save text that people input to a textbox into a .txt using .php so it can be loaded into the textbox everytime somebody sees it using the loadVars function?

Here is what I have so far but it won’t work… I’m very much php illiterate.

$filename = $ai.".txt";
$dir = "/";
$fullpath = $dir.$filename;
$handle = fopen ($fullpath, "w+");

fwrite($handle, $_POST["text"]);

fclose($handle);

I named the php file “comments.php” Then in Flash I put this…

[AS]_parent.loadVariables(“comments.php”);[/AS]

Then I get lost.