Page 1 of 1

PHP password change

Posted: Tue Mar 10, 2009 7:45 pm
by tomsace
Hey,

I have a script on my site to password protect a file.

It has the values:

Code: Select all

$password = "password123";
I want to create a code on another page to be able to edit the password in like a form of some kind.
Is there a way to store the password somewhere and be able to edit it from another page?

Thanks,
Tom.

Re: PHP password change

Posted: Wed Mar 11, 2009 12:07 am
by sparrrow
Database like MySQL would be the primary choice. If that's not an option, you could store it in a text or XML file, then read from/write to that file for your authentication or password change operations. Just make sure to store the file in a directory that is not web visible, so it can only be accessed by your PHP script and not directly from a browser by curious users.

Re: PHP password change

Posted: Fri Mar 13, 2009 2:26 am
by tomsace
Thanks for the help,

I have tried loading the password from a seperate file:

Code: Select all

$password = "include('password.txt');";
but then the password to login to the page isnt the password I store in the file 'password.txt'. It is just 'include('password.txt');'.

How can I load the file to be the password?


Thanks,
Tom.

Re: PHP password change

Posted: Fri Mar 13, 2009 3:38 am
by requinix