title: Simple Contact form that writes to text file from html
body: <p>What I have done so far is built a java based webserver using eclipse. I am able to access an index.html page i created. Now I am trying to create a contact form where a user can enter information and on submit it writes to and amends a text file, clears the form and shows the data users have submitted at the bottom of the page any suggestions.</p>
  
  <p>Note: As per a request I edited this post to include code.</p>
  
  <pre><code>&lt;?php
  $saving = $_REQUEST['saving'];
  if ($saving == 1){ 
  $data = $_POST['data'];
  $file = "data.txt"; 
  
  $fp = fopen($file, "w") or die("Couldn't open $file for writing!");
  fwrite($fp, $data) or die("Couldn't write values to file!"); 
  
  fclose($fp); 
  echo "Saved to $file successfully!";
  
  }
  ?&gt;
  
  &lt;form name="form1" method="post" action="data.php?saving=1"&gt;
  &lt;textarea name="data" cols="100" rows="10"&gt;
  Name: 
  Address: 
  Email: 
  Phone: 
  ---------------------------------------------
  &lt;/textarea&gt;
  &lt;br&gt;
  &lt;input type="submit" value="Save"&gt;
  &lt;/form&gt;
  &lt;p&gt;
  
  &lt;a href="data.txt"&gt;&lt;b&gt;VIEW&lt;b&gt;&lt;/a&gt;
  </code></pre>