Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a text file sec_pwds.txt. In this file I have stored the username and passwords of my site members. Now, I want to put this file outside the root directory for security purpose.
My Question is
If I put this file outside the root directory, How can I use the passwords and usernames from this file in my site using PHP.
Posted

Even though keeping usernames and passwords in some inaccessible files seems to be a good idea, there is no need to keep any passwords in non-encrypted form anywhere. Nobody needs passwords (and nobody should ever see it, developer is administrator — nobody). It you think about it just a bit, you will understand that the original passwords never needed for authentication.

Store only encrypted passworda and encrypt posted password using the same algorithm and compare encrypted with encrypted.

—SA
 
Share this answer
 
Comments
Uday P.Singh 6-Oct-11 1:38am    
Agree my 5!
Sergey Alexandrovich Kryukov 6-Oct-11 1:52am    
Thank you, Uday.
--SA
rashidfarooq 6-Oct-11 1:56am    
Thanks for Answering.
But My real problem is not to storing passwords. I know that passwords must be encrypted before storing. My real problem is if I put a file outside the root directory, how can I access it and how can I use it in my site.
As suggested by SA "Store only encrypted password and encrypt posted password using the same algorithm and compare encrypted with encrypted." You can use MCrypt for encryption.

Refer This[^] for its implementation.
I would prefer to store the password in database rather than storing it in a text file.

hope it helps :)
 
Share this answer
 
v2
Comments
rashidfarooq 6-Oct-11 1:55am    
Thanks for Answering.
But My real problem is not to storing passwords. I know that passwords must be encrypted before storing. My real problem is if I put a file outside the root directory, how can I access it and how can I use it in my site.
Uday P.Singh 6-Oct-11 2:12am    
Does your file exists at server?
rashidfarooq 6-Oct-11 2:15am    
I have not uploaded yet.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900