I'm trying to protect a number of accounts on a Linux server using apache's Basic authentication. I'm looking for a collection of php codes to handle login, logout, creation of user names and passwords, password maintenance, etc, from a web page. My site has a number of user accounts, each of which is accessed of the form: http://site.com/name1. I've set up apache to have a directory block and an htpasswd file for each name. Each account can have multiple user names and passwords.

I currently add user names and passwords manually from the command line, via SSH, but need to enable users to do it themselves for their own account via a web page. Is there a collection of php codes that will do this for me ? I'm not conversant in sql and would like to do this as simply as possible.

Thank you in advance.

closed as off-topic by Steve, S.L. Barth, grochmal, Steffen Ullrich, HashHazard Nov 15 '16 at 21:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.


I do not know that PHP answer, but strongly suggest you don't use Basic Authentication. This is a very poor form of username/password security and is extremely easy to decipher for a website pentester...and an attacker. Please see owasp.org for secure website information. I would think your PHP question would be better answered here: https://stackoverflow.com/questions.

  • Becky, thank you. Folks, it's not just code that I want, it's a recommendation of the best way to do it. This problem has been solved a zillion times, but I can't find it. I'm looking for someone to point me to a "best in class" solution, one with code I can use to implement it easily. – NewtownGuy Nov 17 '16 at 14:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.