hi,
perhaps you could have it work this or similar way:
1. a php script that saves the data to the file, such as
save.php. in that script, you take a GET/POST variable, perhaps do some validation, and update the file. it is a separate script, its only input is GET/POST data, and its only output might be a one word message: success or error, or a number like 1 or 0.
2. a piece of javascript code that sends an ajax request and optionally shows the response. here you make a request to the
save.php and, if needed, show an appropriate message (alert box or whatever) whether the action was successful.
if you are using or willing to use jquery, this link might be useful:
http://api.jquery.com/jQuery.post/