Jump to content

Assign database object as session variable


fawcett44

Recommended Posts

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. 

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.