I need some help though:
I'm just using a text file to store the usernames and passwords just for now for testing and I'm having trouble when it checks if the username already exists or not. Yes it does work but it is case sensitive.
I'm using this code to read usernames and password - it does work fine.
$fp = fopen ( 'users.txt', 'rb' );
while ($line = fgetcsv($fp,100,",")) {
echo "Username: ".$line[0]." || Password: ".$line[1]."<br>"; -- I have this line so it prints each username and password that is in the file
if ( ($line[0] == $username) ) {
echo "<b>Sorry! That user (".$username.") has already been used.</b>";
fclose ( $fp );
exit;
}
}
Example: If I register account 'test'. And then register again as account 'test' it will fail - but if i register with account 'tEst' it will succeed because it checks if the text in the file is EXACTLY equal to the username entered.
So my question: How can I prevent this?
- I was thinking of when it checks the line in the file and username to change it into lowercase so it isn't case senstive.
Is this the best option? If it is, how exactly do I make a variable into lowercase?
Thanks.