TheNotebook Posted April 9, 2011 Share Posted April 9, 2011 Hi, I'm very new to php/mysql, but for a project I'm working on I need to create users that are admins, and normal users. The admins would be able to post news stories, and delete user accounts. Whereas the users would just be able to comment on the news stories. I'm just wondering how I would create a normal 'register' page for both, which has the same fields, but somehow creates some people as admins, and others as normal users... with the ability to limit who can become an admin, so not everyone can register as one. I'm not sure how I would achieve this, or even know how to do it. Does anyone know any tutorials or code on how to achieve this? Your help is greatly appreciated, Thanks. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 9, 2011 Share Posted April 9, 2011 You wouldn't ever assign admin privileges when someone registers. What's to prevent anyone from becoming an admin? If I could guess who you have designated to become admins, I could take over your site by registering as one of them first. You would assign admin privileges by having the 'super/owner' admin assign those privileges to the correct account(s) after they have been created. If you want to pre-designate specific users as admins, you would create those accounts yourself and then distribute the correct username/temporary-password to the correct person. Quote Link to comment Share on other sites More sharing options...
TheNotebook Posted April 9, 2011 Author Share Posted April 9, 2011 Thank you for the quick reply! I did wonder if I'd have to do something along those lines! Do you know how I'd first create the initial admin, then the code to make other users admins? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 9, 2011 Share Posted April 9, 2011 how I'd first create the initial admin You would either have an installation script (that gets removed after you use it) that creates the database record or you would register a normal account and then manually go into the database table and change the type to admin. code to make other users admins? You would create an admin page that only existing logged in admin's can access that would allow you to pick a username and edit his information stored in the database table. Quote Link to comment Share on other sites More sharing options...
spiderwell Posted April 9, 2011 Share Posted April 9, 2011 in sites i have made in the past, i have an auto edit form that pre populates the users info, and depending on if that user is an admin or just a normal user, the user group option is hidden or in a drop down. i.e. an ordinary user will not get the option to change group from user to admin, but the same form viewed by admin will have an extra field with these options. in fact the same form also works for adding new users via the cms backend or as a register form on the front end. 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.