Jump to content

p/w protected members section with ability to recieve documents specific to them


yiaggi

Recommended Posts

Hi guys,

 

I am hoping someone here can help me with a confusing php project I have!? I am not too bad with php and am able to create simple password protected area's etc which, up until now, is all I have really needed.

 

Basically .....

 

I need to create a password protected members area for a website I am building. That in itself is easy enough. The client wants to be able to add new users easily so the user is set up with their own password protected page.

 

When the user logs in they should be presented to a 'global page' which all users can see.

 

I can pretty much cover all that ..... now the bit I can't do ........

 

On the users page there needs to be a link that says "documents". When the user clicks this link it should go through to a further page with their past documents and new documents displayed for download.

 

This is confusing the hell out of me! If I had to do it as a website from my end it would be easy but this all needs to be controlled at the clients end with php. On top of this I have no idea how to enable the client to attch the documents to each users page. They need to be attched monthly to around 500 people.

 

I've thought of easier ways of dealing with the problem but if I can find a system that achieves the above it would make my life easier! We don't mind paying for an already established system if it works well or if someone points me to a decent tutorial that would also greatly help.

 

The important thing is that each user cannot see the others documents.

 

Any help would be very much appreciated - I am slowly learning the wonders of php and will give back to the forum what I can in the future.

 

Cheers guys

 

 

 

 

 

 

So, they upload these documents or what? If they are simply uploading the documents, it won't be very hard at all.

 

A bit more information, then we might be able to give you some guidance.

 

How are the documents placed on the website? Upload? Written?

Do you have a database as a backend?

So, they upload these documents or what? If they are simply uploading the documents, it won't be very hard at all.

 

A bit more information, then we might be able to give you some guidance.

 

How are the documents placed on the website? Upload? Written?

Do you have a database as a backend?

 

Hi there,

 

Thanks very much for your help already.

 

To help you understand a bit - There is 'My End' - 'The Client End' (who i'm building for) and the 'User' (the person with the protected page) ... I know that is obvious but to avoid confusion!

 

The documents will be uploaded by the Client at their end - I can do it myself if that makes it easier?

 

This would be the scenario .....

 

1/ Joe Bloggs (our user) will request their own page.

 

2/ This page can either be set up by me or by the Client at their end.

 

3/ On a monthly basis the Client will recieve documents that they want to distribute to each individual User without the other users seeing any documents but their own.

 

4/ The documents can be uploaded to the server at the Client end or by me .... which ever proves to be the easiest.

 

 

If it was just one or two documents - I would obviously just attach myself and not use PHP to control it but it is hundreds! It would take me forever to create a link and add each document to each clients page - It has to be easier than that!

 

Thanks again for your help :0

 

 

 

 

And do you have a database backend? I'm going to assume you do for my solution.

 

At the moment I'm going to assume that users are stored in a database table like so:

id      username        password

1      john            12345

2      zach            54321

3      sally          34512

 

So when you log users in it should set a session with there username or preferably, there ID (both is good as well). This way, when the access other pages there ID is passed across so you can access the information from the users table again. But as well as that, you can use it for other things.

 

What you can do to handle the documents is create another table called documents or something similar. It can look like this:

 

id    user_id    original_filename    location                          upload_date

1    1          Document 1            /path/to/maj241bfa.doc            31/01/91

2    1          Document 2            /path/to/m12bau41.doc              31/01/91

3    3          Document 3            /path/to/kkmnj1235.doc            31/01/91

 

So the id column is auto_increment, the other columns should be set to their appropriate field types (eg, user_id is int).

 

So what happens, when the client uploads a document, show them a drop down box with all the users names (you can make it even cooler by adding a little JavaScript search to let them track a user down quicker). Now, the value for these drop down options should be the id of the user, like so:

 

<select name="users">
    <option value="1">john</option>
    <option value="2">zach</option>
    <option value="3">sally</option>
</select>

 

So, the rest of the form should have a file upload area and any other details you may want.

 

When the form is submitted you need to do a few things, the main thing being upload the file. Google for a PHP file upload tutorial, and you should find plenty of help. But what I suggest is giving each file a randomly generated name, to avoid conflicting file names. That said, store the original name of the file in a variable so that you can insert that into the database and show that name to the user/client.

So, you've uploaded the file. Now just store the relevant information in the database. Fairly easy really.

 

Once all that is completed, all you need to do for each users protected page is run a query on the database to return all the documents where the user_id column is equal to their ID which you stored in a session variable upon logging in.

 

That's quite a long post, and I haven't really supplied you with much code, just the logic.

Hopefully you're able to make sense of it, and get your project moving forward again.

 

Good luck.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.