title: PHP comparing user input and stored data in XML file for login purpose
body: <p>I want to compare the user input from html file and compare it to XML file using PHP(XML is acting as database in this case, just for learning purpose). This is my current code
  login.php</p>
  
  <pre><code>&lt;?php
  if(count($_POST) &gt; 0)
  {
  $password = @trim($_POST["password"]);
  $email = @trim($_POST["email"]);
  $xml2 = file_get_contents('../../data/customer.xml');
  
  if ((strpos($xml2, "&lt;email&gt;$email&lt;/email&gt;") !== false) &amp;&amp; (strpos($xml2, "&lt;password&gt;$password&lt;/password&gt;") !== false))
  {
      echo 'login succeeded';
      //$_SESSION["custno"] = $custno;
      $_SESSION['user']=(string) $customer-&gt;customerid;
      header("location:buying.htm");
  }
  else
  {
      echo 'Wrong email or password';
  }
  }
  ?&gt;
  </code></pre>
  
  <p>customer.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;customer&gt;
  &lt;user&gt;
      &lt;id&gt;0&lt;/id&gt;
      &lt;fname&gt;John&lt;/fname&gt;
      &lt;lname&gt;Smith&lt;/lname&gt;
      &lt;email&gt;jsmith@gmail.com&lt;/email&gt;
      &lt;password&gt;jsmith&lt;/password&gt;
      &lt;phone&gt;0412345677&lt;/phone&gt;
  &lt;/user&gt;
  &lt;user&gt;
      &lt;id&gt;1&lt;/id&gt;
      &lt;fname&gt;Arthur&lt;/fname&gt;
      &lt;lname&gt;Black&lt;/lname&gt;
      &lt;email&gt;ablack@gmail.com&lt;/email&gt;
      &lt;password&gt;ablack&lt;/password&gt;
      &lt;phone&gt;0412345678&lt;/phone&gt;
  &lt;/user&gt;
  &lt;user&gt;
      &lt;id&gt;2&lt;/id&gt;
      &lt;fname&gt;Brian&lt;/fname&gt;
      &lt;lname&gt;Luo&lt;/lname&gt;
      &lt;email&gt;bluo@gmail.com&lt;/email&gt;
      &lt;password&gt;bluo&lt;/password&gt;
      &lt;phone&gt;0412345678&lt;/phone&gt;
  &lt;/user&gt;
  &lt;/customer&gt;
  </code></pre>
  
  <p>With the current code, any combination of existing email and password will go through. For example bluo@gmail.com with password jsmith will still pass the login page. Any suggestion on how to fix it?</p>