Hi,
I'm trying for some time to get this script to work.
It's a script that can be found all over the Internet.
Whatever I tried, I can't get it to work.
Maybe a simple typo but I cant find it.

It's a 1 field form, posting a text to a file.

The content is not saved to the file, the file ends up empty every time, I get no response in the <status div.

If someone could point me to the error I would be more than grateful.

Thanks
JohN

process-form.php
Code:
<?php 

$myFile = "/home/adm/domains/mydomain.nl/public_html/frm01/clnt01.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $_POST['sc']);
fclose($fh);
echo 'file is ' . $_POST['sc']; // just for testing purpose returning the content

?>
html page
Code:
   <head >

<script type="text/javascript">   
function ajax_post(){
    // Create our XMLHttpRequest object
           var hr = new XMLHttpRequest();
		   
    // Create some variables we need to send to our PHP file
           var url = "process-form.php";
	   var sc = document.getElementById("kontent") . value;
           hr.open("POST", url, true);
		   
		   
    // Set content type header information for sending url encoded variables in the request
           hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		   // hr.setRequestHeader("Content-length", postdata.length);
		   
    // Access the onreadystatechange event for the XMLHttpRequest object
           hr.onreadystatechange = function() {
           if(hr.readyState == 4 && hr.status == 200) {
           var return_data = hr.responseText;
           document.getElementById("status").innerHTML = return_data;
   }
    }
	
    // Send the data to PHP now... and wait for response to update the status div
	// Actually execute the request
	       hr.send(sc); 
           document.getElementById("status").innerHTML = "processing...";
}

</script>   
   </head>
   <body>
<form method="post" action="process-form.php">

          <textarea cols="80" id="kontent" name="kontent" rows="10"><p>initiele tekst ...</p></textarea>
		  
		  <input type="button" value="Submit" onclick="javascript:ajax_post();">
		  
           </form>
		   
	        <div id="status"></div>

   </body>
</html>