Page 1 of 1

How to read and write to a file?

Posted: Sat Jan 28, 2006 2:12 pm
by kaisellgren
I have made login screen, but when the admin has logged, I want that there is change password option. It stores password in php file. How to read from it and how to write to php?

Posted: Sat Jan 28, 2006 3:59 pm
by foobar
Just like from a regular file.

Use fopen() (and the rest of 'em), file() or file_get_contents() to read the file and fwrite() to write.

Posted: Sat Jan 28, 2006 6:12 pm
by shiznatix
you should really look at using a database. its sooo much easier to use and whatnot

Posted: Sun Jan 29, 2006 4:18 am
by kaisellgren
Okay. I have made a mysql database. My admin and password are stored there. But how the php file knows the mysql database name, password and so on...? This script is meant for many users so It must store the mysql connection settings in a file, but then anyone can access it, right?

Posted: Sun Jan 29, 2006 5:10 am
by foobar
kaisellgren wrote:It must store the mysql connection settings in a file, but then anyone can access it, right?
No. Make it a php file that you always include, or better yet, user ezSQL.
As the name states, it's easy to use.