Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How to get admin_level of logged in user!? Reply To: How to get admin_level of logged in user!?

#242540
Ilan Firsov
Participant

Your current script selects the first column (which is admin_level since you select only this one column) of the first row of the result set.
You should modify your query to select the admin_level of a specific user by targeting it with a WHERE clause.
Might be something like the following though it is dependent on your database structure:

<?php
$conn->prepare("SELECT admin_level FROM users WHERE email = ? ");
$sth->execute(array(
    '[email protected]'
));

Also I’d suggest not trying to create your own user authentication system. It is quite hard and very prone to security issues.