php check for matches in txt file
<p>Hi im creating a simple log in system. I'm aware the way im doing is completely unsafe but its just for learning purposes, since im new to php. I'm having trouble with the validation, right now its not reporting if the username or password exists in the txt file. I also gonna use sessions(not fully implemented) to keep track if a user is logged in or not.</p>

<pre><code>         &lt;?php 
      session_start(); // session


       if(isset($_POST['register'])) //  Register USER
    {
      $user  = $_POST['username'];
      $password=$_POST['password'].PHP_EOL;
      $fh = fopen("file.txt","a+");
      fwrite($fh,$user." ".$password); //write to txtfile
      fclose($fh);
    }
</code></pre>

<p>The output in the txt file looks like this:</p>

<pre><code>      user1 password1
      user2 password2
</code></pre>

<p>This is where i need help</p>

<pre><code>      if(isset($_POST['Login']))
      {
      $_SESSION['username']=$user; 
  $_SESSION['password']=$password;

  $file = file_get_contents("file.txt");



 if (strpos($file, "$user $password".PHP_EOL) !== false) 
  {
     // go to login page
  }
  else 
{ 
     //ERROR
}

    ?&gt;
</code></pre>
