|
Posted by Chung Leong on 03/24/06 03:30
carmstrong@cbamedia.com wrote:
> I'm new to PHP and I'm trying to write up a simple PHP login page
> script to authenticate users from a flat file. I've managed to make
> most of it work, except that it only accepts the last user on the
> user/password file, and I'm not sure why. (I.e. the user.txt file is:
It's probably because the text file was created in Windows, where the
line separator is \r\n. When you do the explode on \n, all the elements
except the last will have a \r attached at the end, thus not matching
what was entered.
Use trim() on $username should fix the problem.
[Back to original message]
|