I was just wondering if it would be possible to protect an directory and its content with php http authentication.

Let's say I have created for each user an directory and only that user can access the content in that directory using a mysql database table to get access.

How to protect directory and its content (including images, plain html files, etc).

I now it can be done with .htaccess and .htpasswd.
But my host doesn't support mod_auth_mysql.

I know how to protect a php page with php http authentication and mysql

Recommended Answers

All 4 Replies

The solutions below does not directly solve the problem you have, just alternatives:
1. You could talk to you hosting provider to support 'mod_auth_mysql' or switch to another one that does.
2. You could created protected directory via the cotrol panel (CPanel for example) to your web hosting. Of course, the problem, is that you control the password and the authentication is not routed through the password table in MySQL database.

I've already contacted my web host with the question it they have mod_auth_mysql installed.

The reason why I want to do it this way. Is when users change their password. The htpasswd doesn't have to be changed.

It is no big issue if it can't be done, but would be nice if possible.

Anyway thanks for the quick reply

Do you have to use php authentication? A simple session login system would make it so you can stop people from getting images ect. from other peoples folders.

Do you have to use php authentication? A simple session login system would make it so you can stop people from getting images ect. from other peoples folders.

I haven't thought about that. Thanks for the reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.