title: PHP fwrite new line
body: <p>I'm trying to write username and password to a new line in a txt file.
  The output should be something like this in the txt file.
  I know this is not very secure but its just for learning purposes</p>
  <pre><code>Sebastian   password
  John        hfsjaijn
  </code></pre>
  <p>This is what i have so far</p>
  <pre><code>if(isset($_GET['register'])) //  
  {
      $user  = $_GET['username'];
      $password=$_GET['password'];
      $fh = fopen(&quot;file.txt&quot;,&quot;a+&quot;);
      fwrite($fh,$user.&quot;\n&quot;); //write to txtfile
      fwrite($fh,$password.&quot;\n&quot;); // write to txtfile
      fclose($fh);
  }
  </code></pre>
  <p>EDIT: Here's the solution for me:</p>
  <pre><code>if (isset($_POST['register'])) {
     $user  = $_POST['username'];
     $password = $_POST['password'].PHP_EOL;
     $fh = fopen(&quot;file.txt&quot;,&quot;a+&quot;);
     fwrite($fh,$user.&quot; &quot;.$password); //write to txtfile
    
     fclose($fh);
  }
  </code></pre>