matching login info to external file php <p>I have html registration form with username and password inputs. Usernames and passwords are stored in <code>.txt</code> file like this:</p> <pre><code>username1,password1 username2,password2 </code></pre> <p>I need to match entered username and password with the stored ones. This is my code, but something is not working, can somebody advise? </p> <pre><code>&lt;form action = "./get_form.php" method = "post" name = "form" &gt; Username: &lt;input type= "text" name = "username" &gt; Password: &lt;input type= "text" name = "passwords" &gt; Remember me: &lt;input type= "checkbox" name = "remember" value = "checked" &gt; &lt;input type = "submit" name = "submit" value= "Submit Query" &gt; &lt;/form&gt; &lt;?php $username= $_POST["username"]; $password= $_POST["password"]; $contents = file("passwords.txt"); $found = false; foreach ($contents as $line) { $data = explode(',', $line); if (($username === $data[0]) &amp;&amp; ($password === $data[1])) { $found = true; } } ?&gt; </code></pre>