Why would you use a php file for storage of usernames and passwords? It's pretty standard (and simple nowadays) to use a database for username / password retrieval.
That being said, you don't want to store the password in plain text in the database.
PHP 5.5 has a whole new set of password functions coming out, so how about you use a library that allows for forward compatibility of these functions? Password_compat.
The point is, you include the file, use it's functions, and then when 5.5 comes out, you just remove the include and all the functions will still work because they're part of core.
It's really simple to use:
- Hash the password using
password_hash()
- Store the username and hash in the database
- When logging in, use
password_verify()
to verify the password sent in $_POST against the hash in the database.
That's it! Simple, secure, forward compatible. Highly recommended over flat file storage.
You really should take the time to learn MySQL. However, it's great to code to an interface rather than a concrete implementation and switch out one type of storage for another any time you want.
That being said, hash your passwords and usernames and, if you must, write them to a file. At least they'll be hashed, and not in plain text. You can still use the functions described above.
You can even serialize()
your array and write that to a file, then unserialize()
it on the way back. But I'd really recommend taking the time out to learn the basics of MySQL, you'll pick it up in no time at all.