stuaz Posted November 30, 2010 Share Posted November 30, 2010 Hi, so far I have managed to set up a somewhat basic login website with a mysql database backend. Once they have logged on they go to a "main menu" page. What I need to define is that user A sees button A but only that button, etc. (Then of course that same rule would have to apply if they tried to directly go to the page, but I am guessing I can do that in the same way that I currently do to force a login). If anyone has any tutorials or sample code I would much appreciate it. Thanks, Quote Link to comment Share on other sites More sharing options...
jdavidbakr Posted November 30, 2010 Share Posted November 30, 2010 Depending on what level you need to control it, you probably will need to make a table that defines what buttons each user sees. Then do a select from that table to get the buttons (using the logged in user_id), and iterate through the result set to draw each button. If your buttons table had three columns - user_id, link, and button_image, you could draw it with something like this: $statement = "select * from buttons where user_id = '{$login_id}'"; $result = mysql_query($statement); while ($row = mysql_fetch_assoc($result)) { echo '<a href="'.$row['link'].'"><img src="'.$row['button_image'].'"></a>'; } Quote Link to comment Share on other sites More sharing options...
stuaz Posted November 30, 2010 Author Share Posted November 30, 2010 Thanks for the quick comment. Yeah I have kinda planned a table - I have a members table at the moment. I figured I could put in another table (Didn't think it would be wise to have it in the same one?). Currently the structure is: <userid> - <button>. But if I understand correctly, what your saying is to store in the table the code for the button? Could I not so something like: Select button from "menu table" where userid = $loginid if "result" = menu1 then blah or if result = menu2 then blah Or is that what you code is saying? Excuse my ignorance. Quote Link to comment Share on other sites More sharing options...
shlumph Posted November 30, 2010 Share Posted November 30, 2010 You might want to have a set of privileges for each user, and depending on the users privileges, they see a certain thing. You could also assign each user with a certain privilege level (ie: 10, 20, 30, etc.) and depending on their privilege level, they see a certain thing. You could also assign each user a certain role (guest, agent, admin, etc.), and depending on their role, they see a certain thing. Or a mixture of all three... it all really depends on how you want to set it up. Quote Link to comment Share on other sites More sharing options...
stuaz Posted November 30, 2010 Author Share Posted November 30, 2010 You could also assign each user with a certain privilege level (ie: 10, 20, 30, etc.) and depending on their privilege level, they see a certain thing. You could also assign each user a certain role (guest, agent, admin, etc.), and depending on their role, they see a certain thing. I like the sound of both. lol. I am doing the website for different "regions" of the country, so one region sees other "button" than another, etc. So it would be good to do: Region A sees buttons A,B,C Region B sees buttons 1,2,3? Quote Link to comment Share on other sites More sharing options...
jdavidbakr Posted November 30, 2010 Share Posted November 30, 2010 You could also assign each user with a certain privilege level (ie: 10, 20, 30, etc.) and depending on their privilege level, they see a certain thing. You could also assign each user a certain role (guest, agent, admin, etc.), and depending on their role, they see a certain thing. I like the sound of both. lol. I am doing the website for different "regions" of the country, so one region sees other "button" than another, etc. So it would be good to do: Region A sees buttons A,B,C Region B sees buttons 1,2,3? That makes sense. It pretty much boils down to coming up with a schema that fits your requirements. If each user has a region value in their table, then you just link the regions to the buttons that they see and you should be good to go. Quote Link to comment Share on other sites More sharing options...
stuaz Posted November 30, 2010 Author Share Posted November 30, 2010 So it would be a case of saying in the database - User A Region 1 User B Region 2 Then in the code, I would say that if the results return are "Region 1" then show Buttons "1,2,3" Is that the kinda thing? Think I may need to learn some more PHP then Quote Link to comment Share on other sites More sharing options...
jdavidbakr Posted November 30, 2010 Share Posted November 30, 2010 So it would be a case of saying in the database - User A Region 1 User B Region 2 Then in the code, I would say that if the results return are "Region 1" then show Buttons "1,2,3" Is that the kinda thing? Think I may need to learn some more PHP then You can do that with a simple switch statement if it's that trivial, just assign $region from the logged in user's info: switch($region) { case 1: // Draw the buttons for region 1 break; case 2: // Draw the buttons for region 2 break; } Quote Link to comment Share on other sites More sharing options...
stuaz Posted November 30, 2010 Author Share Posted November 30, 2010 Brilliant, thank you for the help Quote Link to comment Share on other sites More sharing options...
stuaz Posted December 2, 2010 Author Share Posted December 2, 2010 Just a quick query slightly related to this - I am trying to embed a flash image into a page using: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/ swflash.cab#version=6,0,29,0" width="600" height="400"> <param name="movie" value="10-OCT-salesappraisal.swf"> <param name=quality value=high> <embed src="http://locahost/dashboards/10-OCT-salesappraisal.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi ?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="600" height="400"></embed> </object> I have tried putting: <?php require_once('auth.php'); ?> but it will not ask to login if I am not, it sill just loads up the page with no issues! It works on normal PHP pages. Quote Link to comment 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.