riki maru
riki maru

Reputation: 71

Check status for current logged user

I have table with next values..

id------username-----password------status
1---------derek--------123---------admin
2----------rob---------321---------worker

After login which is working right i need to check on landing page if user has status admin so i could add another html tables and forms for him.

I realize that the query must be something like this.

SELECT * FROM users where username = '$login_session' and status="status"

What is the right way for doing this ?

Upvotes: 2

Views: 149

Answers (1)

Mureinik
Mureinik

Reputation: 311808

If you want to get the statue back to the application, just select it:

SELECT status
FROM   users
WHERE  username = '$login_session'

Mandatory comment:
Using string evaluation in SQL queries is a bad practice that leaves your application open to SQL-injection attacks. Instead, you should consider using a prepared statement.

Upvotes: 2

Related Questions