Hi guys,
I am fairly new to php and whilst I understand how to put together a login function - once it goes past there I really start to struggle! I was hoping one of you guru's can help me out!
Basically - I have a website with 100 members who each have a password protected page. Each month I want to give each member a link to a PDF that is specific to them. They cannot view anyone elses PDF but their own. Having researched - I sussed out that the best way to do this is to store the PDF's in a non-web accessible folder and use php to deliver the PDF when the relevant link is clicked by the user. Knowing I have to do this and delivering are 2 different things though!
This would be the path:
1/ User clicks link on his page ie: "Barry's PDF number 1"
2/ Link goes to PHP page that checks that the user is logged in (I have this script from the original login) and then checks it against the requested PDF
3/ PDF is delivered to the server.
It may sound like I know what im doing but am totally confused about the code it takes to implement this! Am I right in thinking that I need to use the php INCLUDE function to call the PDF's? If any one can give me an example of how it would look I would be forever grateful!
callng non-web accessible files (pdf's)
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: callng non-web accessible files (pdf's)
You pretty much have the theory behind is.. however, I would recommend using readfile() to output the file through PHP. The manual for that function has a ton of user examples of headers you should be sending as well.
Re: callng non-web accessible files (pdf's)
thanks very much for your answer mateJohn Cartwright wrote:You pretty much have the theory behind is.. however, I would recommend using readfile() to output the file through PHP. The manual for that function has a ton of user examples of headers you should be sending as well.
I think the thing that is really confusing me is the "non-web accessible" part! My server people have set up another folder on my server to play the part for me and have given me c:\mypdffolder (obviously changed that but the same root etc) as the directory to access it. I guess my brain will not compute the fact that should someone type this into a browser it wont access the file but can be accessed using php ...... How does this work?!