Creating a Registration and Login Page
<p>I'm currently in the process  of making a Registration and Login Page. My first page asks you if you want to create an account or login. What we have to do is take the information from the form that the user enters information into, and place it into a text file. I've got this working roughly. I understand that this is not good practice for security reasons, but this is an assignment for class and I MUST put the information into the text file. I have the information going into the text file, however I am having trouble comparing the posted username to all of the usernames inside of the database. Here is my code for the newaccount.html page, and the register.php file that the form submits to.</p>

<p><strong>newaccount.html</strong></p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;h3&gt;Hello new user! Choose a user name and password ^_^&lt;/h3&gt;&lt;br&gt;

&lt;form action = "register.php" method = "POST" &gt;
Username: &lt;input type = "text" name = "username"&gt;&lt;br&gt;&lt;br&gt;
Password: &lt;input type = "password" name = "pass"&gt;&lt;br&gt;
&lt;input type = "submit" value = "Create Account" name = "submit"&gt;&lt;br&gt;
&lt;/form&gt;
&lt;form method = "LINK" action = "Proj2_practice.html"&gt;
&lt;input type = "submit" value = "Home Page" name = "submit2"&gt;
&lt;/form&gt;

&lt;/body&gt;  
&lt;/html&gt;
</code></pre>

<p><strong>register.php</strong></p>

<pre><code>&lt;?php

$username = $_POST['username'];
$password = $_POST['pass'];

$userAndPass = $username.",".$password;

$userNames = 'usernames.txt'." ";
$passwords = 'passwords.txt'." ";

$fh_users = fopen($userNames, 'a+')or die("sorry, we couldnt open the file");
$fh_passwords = fopen($passwords, 'a+')or die("sorry, we couldnt open the file");

fwrite($fh_users, $username." ");
fwrite($fh_passwords, $password." ");

$allUserNames = fread($fh_users, filesize('usernames.txt'));

echo $allUserNames;

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

<p>The usernames and passwords are being sent to the text files correctly, At the end of the code, it is not echoing the variable. As of right now, there is no information in the text files, I don't know if that is the reason that nothing is being echoed. Is my approach correct here? What I'm trying to do here is send each name and password to a username and password text file.Then, Im planning on</p>

<p>exploding each of those text files by a space between them, which is why I add one after writing them to the text file, and then comparing the usernames and the passwords by their respective array elements. Am I overcomplicating this as much as I think I am? Please share your comments with me, I'm just trying to get better ^_^</p>

<p>Thank you in advance!</p>
