flipper828 Posted January 24, 2013 Share Posted January 24, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/273587-secure-user-view/ Share on other sites More sharing options...
White_Lily Posted January 24, 2013 Share Posted January 24, 2013 how are you storing the downloads? (file names specifically)? Quote Link to comment https://forums.phpfreaks.com/topic/273587-secure-user-view/#findComment-1407949 Share on other sites More sharing options...
PFMaBiSmAd Posted January 24, 2013 Share Posted January 24, 2013 If you have a login script, you have a session variable that contains the user_id of the logged in member. You would use that user_id to filter the content/data that the page produces so that only the items that belong to that user are displayed. Quote Link to comment https://forums.phpfreaks.com/topic/273587-secure-user-view/#findComment-1407953 Share on other sites More sharing options...
Psycho Posted January 24, 2013 Share Posted January 24, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/273587-secure-user-view/#findComment-1407958 Share on other sites More sharing options...
flipper828 Posted January 24, 2013 Author Share Posted January 24, 2013 Oh thank you so much for steering me to the right direction! This will be a lot easier than I thought. You lot are the best! Quote Link to comment https://forums.phpfreaks.com/topic/273587-secure-user-view/#findComment-1407962 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.