Jump to content

Username?


aaronmc123

Recommended Posts

There is no way for us to answer this for you as we know nothing about your current application. Are you storing any information about the uploads now that is separate from the files themselves? If you are storing information in a database, then you would want to add an additional column in the table to store a foreign key reference back to the user who uploaded the file.

 

If you have a user based system then you should have some means of knowing who the user is (SESSION, COOKIE< etc.) - so you should already have the users ID. So, when the user submits a file you would get that value and include it with the other data you are storing. Again, no idea how to tell you actually how to do this since I have no knowledge of your current code.

 

Then when you display the file (or more likely a link to the file) you would query the database for the information you were previously displaying and you would use the foreign key reference for the user ID to join the users table to also get the username.

Link to comment
Share on other sites

Since I know nothing about your code, I'll improvise.

 

1. In your login, you should have a user_id. ($_SESSION['user_id'])

 

2. In the database, the uploads table should have columns uploader_id.

  When you upload the file, the query should contain:

 

$query = "INSERT INTO uploads SET uploaded_file = $file, uploader_id = $_SESSION['user_id'] ";

 

3. When printing out the upload, the query should have this:

 

$query = "SELECT uploaded_file_id, uploaded_file, username FROM uploads JOIN users ON uploads.uploader_id=users.user_id";

 

And then when you print out username, you'll get your user who uploaded the file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.