4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 PHP and Password Protected Directories
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
naturegrapher
Junior WebHelper
Junior WebHelper


Joined: 25 Mar 2006
Posts: 2

PostPosted: Sat Mar 25, 2006 11:49 pm (18 years ago) Reply with QuoteBack to Top

I've set up a PHP and MySQL member section on my website, but want to display some images that only members can access. The script lets users onto a PHP page, which detects a cookie to see if they're logged in. If the page does not detect a cookie, the code stops and only the header of the page is shown. I need to display images that are for members only, but am concerned that people will just go to my images directory and find them on their own. I was wondering if PHP could log into a password protected directory which uses .htaccess.

Thanks for any input, or a new way around this problem.
OfflineView User's ProfileFind all posts by naturegrapherSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Mon Mar 27, 2006 2:24 pm (18 years ago) Reply with QuoteBack to Top

I'm not sure you'll have much success with using Apache's password protection (unless you want to put the username/password in the image URL and somehow sync your database with the htpasswd file - not what I'd recommend doing).

What I would do is place all the members-only images in a directory which isn't accessible directly via Apache. Then, use a PHP script to check the user's authentication cookie, then use readfile() to send the image to the user.

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
naturegrapher
Junior WebHelper
Junior WebHelper


Joined: 25 Mar 2006
Posts: 2

PostPosted: Mon Mar 27, 2006 8:39 pm (18 years ago) Reply with QuoteBack to Top

Thanks, Adam!
I'm an extreme beginner at PHP and MySQL, and I don't exactly get what you're saying (sorry!). Do you have a PHP script example to get me going on the right track? Thanks a bunch!
OfflineView User's ProfileFind all posts by naturegrapherSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Mon Mar 27, 2006 9:24 pm (18 years ago) Reply with QuoteBack to Top

I don't have any examples handy, and don't really have the time to write one. The PHP manual might be a good place for you to start: http://www.php.net/readfile

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.22097 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme