|
Author |
Message |
naturegrapher
Junior WebHelper
Joined: 25 Mar 2006
Posts: 2
|
Posted:
Sat Mar 25, 2006 11:49 pm (18 years, 7 months ago) |
|
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. |
|
|
|
|
adam
Forum Moderator & Developer
Joined: 26 Jul 2002
Posts: 704
Location: UK
|
Posted:
Mon Mar 27, 2006 2:24 pm (18 years, 7 months ago) |
|
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... |
|
|
|
naturegrapher
Junior WebHelper
Joined: 25 Mar 2006
Posts: 2
|
Posted:
Mon Mar 27, 2006 8:39 pm (18 years, 7 months ago) |
|
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! |
|
|
|
|
adam
Forum Moderator & Developer
Joined: 26 Jul 2002
Posts: 704
Location: UK
|
Posted:
Mon Mar 27, 2006 9:24 pm (18 years, 7 months ago) |
|
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... |
|
|
|
|
|
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.133574 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |