|
Author |
Message |
naturegrapher
Junior WebHelper
![Junior WebHelper Junior WebHelper](images/rank_1.gif)
Joined: 25 Mar 2006
Posts: 2
|
Posted:
Sat Mar 25, 2006 11:49 pm (18 years, 2 months ago) |
![Reply with Quote Reply with Quote](templates/4WebHelp2/images/lang_english/icon_quote.gif) ![Back to Top Back to Top](templates/4WebHelp2/images/icon_up.gif) |
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. |
|
|
![Offline](templates/4WebHelp2/images/offline.gif) ![View User's Profile View User's Profile](templates/4WebHelp2/images/lang_english/icon_profile.gif) ![Find all posts by naturegrapher Find all posts by naturegrapher](templates/4WebHelp2/images/lang_english/icon_search.gif) ![Send Personal Message Send Personal Message](templates/4WebHelp2/images/lang_english/icon_pm.gif) |
![](images/spacer.gif) |
adam
Forum Moderator & Developer
![](images/rank_6.gif)
Joined: 26 Jul 2002
Posts: 704
Location: UK
|
Posted:
Mon Mar 27, 2006 2:24 pm (18 years, 2 months ago) |
![Reply with Quote Reply with Quote](templates/4WebHelp2/images/lang_english/icon_quote.gif) ![Back to Top Back to Top](templates/4WebHelp2/images/icon_up.gif) |
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... |
|
![Offline](templates/4WebHelp2/images/offline.gif) ![View User's Profile View User's Profile](templates/4WebHelp2/images/lang_english/icon_profile.gif) ![Find all posts by adam Find all posts by adam](templates/4WebHelp2/images/lang_english/icon_search.gif) ![Send Personal Message Send Personal Message](templates/4WebHelp2/images/lang_english/icon_pm.gif) ![Visit Poster's Website Visit Poster's Website](templates/4WebHelp2/images/lang_english/icon_www.gif) |
![](images/spacer.gif) |
naturegrapher
Junior WebHelper
![Junior WebHelper Junior WebHelper](images/rank_1.gif)
Joined: 25 Mar 2006
Posts: 2
|
Posted:
Mon Mar 27, 2006 8:39 pm (18 years, 2 months ago) |
![Reply with Quote Reply with Quote](templates/4WebHelp2/images/lang_english/icon_quote.gif) ![Back to Top Back to Top](templates/4WebHelp2/images/icon_up.gif) |
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! |
|
|
![Offline](templates/4WebHelp2/images/offline.gif) ![View User's Profile View User's Profile](templates/4WebHelp2/images/lang_english/icon_profile.gif) ![Find all posts by naturegrapher Find all posts by naturegrapher](templates/4WebHelp2/images/lang_english/icon_search.gif) ![Send Personal Message Send Personal Message](templates/4WebHelp2/images/lang_english/icon_pm.gif) |
![](images/spacer.gif) |
adam
Forum Moderator & Developer
![](images/rank_6.gif)
Joined: 26 Jul 2002
Posts: 704
Location: UK
|
Posted:
Mon Mar 27, 2006 9:24 pm (18 years, 2 months ago) |
![Reply with Quote Reply with Quote](templates/4WebHelp2/images/lang_english/icon_quote.gif) ![Back to Top Back to Top](templates/4WebHelp2/images/icon_up.gif) |
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... |
|
![Offline](templates/4WebHelp2/images/offline.gif) ![View User's Profile View User's Profile](templates/4WebHelp2/images/lang_english/icon_profile.gif) ![Find all posts by adam Find all posts by adam](templates/4WebHelp2/images/lang_english/icon_search.gif) ![Send Personal Message Send Personal Message](templates/4WebHelp2/images/lang_english/icon_pm.gif) ![Visit Poster's Website Visit Poster's Website](templates/4WebHelp2/images/lang_english/icon_www.gif) |
![](images/spacer.gif) |
|
|
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.117961 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |