Page 1 of 1

How to change passwords using PHP

Posted: Fri Dec 01, 2017 10:58 pm
by Joeldcruz
Hi,

I want to allow users to change their password and their password is stored in a file called user_data.txt. How can I allow them to edit their password using solely php?

Thanks!

Re: How to change passwords using PHP

Posted: Fri Dec 01, 2017 11:12 pm
by requinix
How are you storing the passwords? And please tell me that file is not stored under your web root in a web-accessible location.

Re: How to change passwords using PHP

Posted: Sun Dec 03, 2017 4:40 pm
by Christopher
It really depends on the file format. If delimited, you'll have to write from the point of the change to the end of file. If fixed width, then you could just seek, read, seek write.

I'd recommend SQLite if you really need a file based database (http://php.net/manual/en/book.sqlite3.php) it has file locking that will protect against two users writing at the same time and corrupting the file.