Jump to content

Secure User View


flipper828

Recommended Posts

Where to start? First, I am very much a novice to coding in general. I've had beginner and intermediate php classes and I love working with php.

 

I've had a site with a login/password security in place for some time. However, I would like to add a page in which the user can go to see all downloads meant for them and not all available downloads.

 

The problem is, I don't know where to start. I've done some "googling" but apparently I don't even possess the correct terminology to do a helpful search. All I am coming up with is help to create a login/pasword site.

 

Would one of you offer some advice on where I need to start.

 

Thank you in advance for your help.

Link to comment
Share on other sites

If you have already created a login process you are 80% there. As part of the login you should be storing some information to identify the user within session data - typically this could be the user ID. Also, if you have specific downloads for each user you *must* have that information stored somewhere such as a database. And that information should be tied to the user in some way (e.g. the user ID). So, on the page to display the downloads you would just use the user ID stored in the login session data to query the available downloads for that user.

 

If you have some downloads that are available to more than 1 person, then you should at least have two tables: 1 to describe the downloads and another to specify which DLs belong to which users. So, the code could look something like this:

 

if(!isset($_SESSION['user_id'])
{
   //redirect to login page
   exit();
}

$userID = intval($_SESSION['user_id']);
$query = "SELECT name, path
         FROM downloads
         JOIN user_downloads USING(download_id)
         WHERE user_downloads.user_id = $userID";

//Execute query and output the results

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.