View Full Version : Password Protect a file/folder

02-10-2011, 07:34 AM
I'm new to this forum and to PHP, so I hope I am posting this in the right area.

I have this PHP login script where the user logs in and is able to view protected pages. When I create a separate folder at mydomain.net/videos that I want to password protect so that only a registered user who are logged in can access the video content within that folder. But I know you could just go directly to mydomain.net/videos and go around the login script and access the files without being logged in. Suggestion or help is much appreciated

The script that I am using is from http://php-login-script.com

02-11-2011, 06:03 AM
Turn off directly indexes in Apache, or put a blank index.html file in the folder and no one will be able to go around your script to see a filename.

The easiest way to do password protection will be protecting the folder with .htpasswd not with a php script, as that will be on every file in the folder.

Unable to do that, you will need to pipe the content through a PHP script if you're relying on PHP for authentication. And... ideally... store the content below your web root so it isn't publicly accessible directly.

I've piped images through a PHP script, not videos, but it'd be the same thing, you have PHP output the right mime type header, and then just load and ouput the video.

04-18-2011, 12:39 PM
Hi everyone need help i am using Sitebuilder through Fast Hosts and am setting up the pages i need to password protect the pages with differet access to differet pages how can i do that