When accessing a database in PHP you first don't have to bother of whom the data might belong to. You can access all of them and sort out which of them is available for the user and which of them not.
Example
The database for the user looks like this:
ID Name
1 gpdrums
2 sDJh
Now you need a connection to your files. This looks something this that:
ID Name User
100 coffee.pdf 1 ;which is for you
101 tea.odt 2 ;which is for me (I prefer tea =))
Thirdly you need a folder to save your files in. Create one and set a .htacces to it, so that noone can access it via HTTP. Save the files with the fileid only, eg "100" for coffee.pdf.
Now write a PHP-code that does the following:
- user logs in and you find the ID (you=1)
- access the db and just fetch just the columns where the `user` is 1 (you)
- print all these files.
Now you hav a very simple but working fronted.
Secondly, write an output for the files, because you want to restrict it with PHP:
- again check the SESSION/COOKIE for the userid
- check if the file the user wants to download has the permission.
- if yes:
header("Content-Type: mime"); //<- modifies the header so that the browser believes it is a file
header("Content-Length: ".filesize($file));
@readfile($file); //<- outputs the complete content of the file.
Where $file is the path to the file that is saved ("./yourdir/1").
The user now get's the usual promt ("Do you really want to save this file?").
Basically, that's all. The files cannot be accessed by simpy typing the complete address in the browser (Authorization required). But the PHP-runtime can read and output them. You'll have a bit fuss the download (I just finished a similar project). For example you have to set the content-disposition and you can force the browser to use the name of your original file (the user sees "coffee.pdf"). But there a dozens of information on the net.
I hope that helps. If you still have problems, I can have a look in my old codes (I hate reading old codes because they are always very untidy) and send you some pieces of them.
Regards
Simon