PHP password change

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tomsace
Forum Contributor
Posts: 167
Joined: Thu Jan 01, 2009 8:07 pm

PHP password change

Post 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.
sparrrow
Forum Commoner
Posts: 81
Joined: Mon Oct 20, 2008 12:22 pm

Re: PHP password change

Post 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.
tomsace
Forum Contributor
Posts: 167
Joined: Thu Jan 01, 2009 8:07 pm

Re: PHP password change

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP password change

Post by requinix »

Post Reply