fawcett44 Posted December 8, 2007 Share Posted December 8, 2007 Hi All, I am trying to assign a value taken from an SQL database and insert it into a session variable. [What im doing - I am attempting to create a login section (which i have already done) but also assign to say wether a user is a normal user or is an admin user. I have set my database to have the field 'user_type' with a value of either 1-'Admin' or 2-'User'. When i log in i have set set the form/formaction page to check if there is a matching record, if there is the session variable = user name(from form), how can i now retrieve the matching user_type and insert that into a session variable and then. i believe it would be a select statement 'Select * from login_table where username = $username AND user_type = 1; and then 'if rows retrieved = 1 SESSION_VARIABLE['Admin_user'] = $username HEADER = main.php ELSE header = main.php (without sessionvariable). now if i try to enter an admin area it will allow the admin because they have admin session variable set but non admin will be reverted to another page.) Sorry for the long explanation. I feel i am close but it just doesnt seem to be working. Amy halp is greatly appreciated. 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.