title: PHP login from text file
body: <p>Hi I have looked at other posts about this but they are 2 or more years old so I thought it was better to start fresh.</p>
  
  <p>As the title suggests I am trying to make a login page with php. Users should be able to login to a special member only page. The usernames and passwords are stored in a textfile (note this is for an assignment otherwise I'd use SQL). My code is below </p>
  
  <pre><code>  ?php
  
    echo "Username: &lt;input type=\"text\" name=\user-name\"&gt;&lt;br&gt;";
   echo "Password: &lt;input type=\"text\" name=\pass-word\"&gt;&lt;br&gt;";
   echo "&lt;input type=\"submit\" value=\"login\" name=\"login\"&gt;&lt;br&gt;";
  
  $userN = $_POST['user-name'];
  $passW = $_POST['pass-word'];
  $userlist = file ('users.txt');
  $checkUser =$userlist[0];
  
  if (isset($_POST['login']))
  {
  if ($userN == $userlist)
  {
      echo "&lt;br&gt; Hi $user you have been logged in. &lt;br&gt;";
  }
  else
  {
  echo "&lt;br&gt; You have entered the wrong username or password. Please try again. &lt;br&gt;";
  }
  }
  ?&gt;
  &lt;form action="login.php" method="post"&gt;
  Username: &lt;input type="text" name="username"&gt;
  &lt;br /&gt;
  Password: &lt;input type="password" nme="pass"
  &lt;br /&gt;
  &lt;input type="submit" name="submitlogin" value="Login"&gt;
  </code></pre>
  
  <p></p>
  
  <p>I know I need to use the explode function and I need to define how the text file will be set out. ideally username|password. in a file called users.txt The users file also has to contain information such as the email (can replace username) the customers name, the business name (of the customer) and special prices for members. </p>