title: Write a new line on a txt file with PHP?
body: <p>I Want to create txt file with PHP, that can save the data after input on Form. </p>
  
  <p>So far I have been trying this Script</p>
  
  <pre><code>&lt;?php
  
  if(isset($_POST[S1]))
  {
     $name = $_POST[name];
     $email = $_POST[email];
  
     $fp = fopen("formdata.txt", "w") or exit("Unable to open file!");
     $savestring = $name . "," . $email . "\n";
  
     fwrite($fp, $savestring);
  
     fclose($fp);
     echo "&lt;h1&gt;You data has been saved in a text file!&lt;/h1&gt;";
  
  ?&gt;
  &lt;form name="web_form" id="web_form" method="post" action="coba.php"&gt;
          Enter name: &lt;/label&gt;&lt;input type="text" name="name" id="name" /&gt;
          Enter email: &lt;/label&gt;&lt;input type="text" name="email" id="email" /&gt;
          &lt;input type="submit" name="S1" id="s1″ value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>It Work fine and can write to file after Input Form, but if I do the second input, the txt file change to the last input. </p>
  
  <p>How can I do when the second input, the last input write a new line on txt file?</p>
  
  <p>May be the explanation is unclear this the example</p>
  
  <pre><code>    ===============================
      First Input:
      Result Txt File:
  
      Adam, Adam@email.com
      ===============================
      Second Input:
      Result Txt File:
  
      Adam, Adam@email.com
      Eve, Eve@gmail.com
      =============================== 
  </code></pre>
  
  <p>Anyone can help me to Fix it?
  Im very Appreciated your answer.</p>
  
  <p>Thanks</p>