title: php passwords in a txt file as database
body: <p>I've got this login code (I'm conscious it is really unsafe).</p>
  
  <p>How could I store multiple passwords in a .txt file?</p>
  
  <pre><code>   &lt;?php 
  
  $passwords = file('pass.txt');
  
  
  # Check for session timeout, else initiliaze time
  session_start();
  if (isset($_SESSION['timeout'])) {
      if ($_SESSION['timeout'] + 10 &lt; time()) {
          session_destroy(); } }
  else {
      $_SESSION['pass']="" ;  $_SESSION['timeout']=time(); }
  
  # Store POST data in session variables
  if (isset($_POST["pass"])) {
      $_SESSION['pass']=hash('sha256',$_POST['pass']) ; }
  
  # Check Login Data. Password is hashed (SHA256). In this case it is 'admin'.
  $flag = 0;
  foreach ($passwords as $pass) {
      if ($pass == $_SESSION['pass']) {
        $flag = 1;
      }
  }
  
  if ($flag == 1) {
  echo 'session';}
  else {
      echo'&lt;form method="POST" action=""&gt;&lt;input type="password" name="pass"&gt;&lt;/form&gt;';}
  
  ?&gt;
  </code></pre>
  
  <p>This is pass.txt, from which I want to read the passwords</p>
  
  <pre><code>65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5
  5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
  8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
  </code></pre>