title: Javascript page to send credentials
body: <p><strong>JavaScript File</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  
  function send()
  {
  var xmlhttp;
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
  else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  
  
  
  
  xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
      {
      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
      }
    }
  
  xmlhttp.open("POST","192.168.0.10/unp.php",true);
  xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  xmlhttp.send(encodeURI("Username="+document.form1.uname.value+"&amp;password="+document.form1.pass.value));
  
  
  
  
  
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;form name="form1" method="post"&gt;
  USERNAME:&lt;input type = "text" name="uname"&gt;&lt;br&gt;
  PASSWORD:&lt;input type = "password" name="pass"&gt;
  
  
  &lt;br&gt;
  
  
  
  &lt;input type="submit" onclick="send()"&gt;
  &lt;/form&gt;
  &lt;div id="myDiv"&gt;&lt;p&gt;How are You &lt;/p&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>PHP file running on the server</strong>. I want to store the credentials in a file on the server</p>
  
  <pre><code>&lt;?php
  $myfile="testfile.txt";
  $fh=fopen($myfile,'a');
  $stringdata=$_POST["Username"];
  $stringdata1=$_POST["password"];
  fwrite($fh,$stringdata);
  fwrite($fh,$stringdata1);
  fclose($fh);
  ?&gt;
  &lt;html&gt;
  Details Submitted
  &lt;/html&gt;
  </code></pre>
  
  <p>The client page loads without error. The file textfile doest get created though.
  The response also is not returned. Is the Js file correct?</p>