Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

60
Views
Set Login Role using php jquery

Anyone Help me To set Login Role for Admin and user the user its already working but I don't know how to put admin login code on a login user

function login2(){
    extract($_POST);
    $qry = $this->db->query("SELECT * FROM user_info where email = '".$email."' and password = '".md5($password)."' ");
    if($qry->num_rows > 0){
        foreach ($qry->fetch_array() as $key => $value) {
            if($key != 'passwors' && !is_numeric($key))
                $_SESSION['login_'.$key] = $value;
            $this->db->query("UPDATE user_info set attempts = '0' where email = '".$email."' and password = '".md5($password)."' ");

        }
        $ip = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
        $this->db->query("UPDATE cart set user_id = '".$_SESSION['login_user_id']."' where client_ip ='$ip' ");
            return 1;
    }else{
        $_SESSION['attempts'] += 1;
        $this->db->query("UPDATE user_info set attempts = '".$_SESSION['attempts']."' where email = '".$email."' ");
        $this->db->query("UPDATE user_info set password = 'sfsdfsdfdsfsdf435345435j3k5h35498f7dsf' where attempts >= 3 ");
        return 3;
    }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can add a column in your users table named user_role or role or something like that for role and use it like 1 for Admin, 2 for User, when user attempts login get the user_role value from your users table and store it in your login session along with other user details. Once you have the role in your session you can easily manage user privileges as per their role.

Your table will be like

id username password user_role
1 Admin sfsdfsdfdsfsdf435345435j3k5h35498f7dsf 1
2 User 1 sfsdfsdfdsfsdasfasf35j3k5h35498f7dsf 2
3 User 2 sfsasdfasfasf43534535j3k5h35498f7dsf 2
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!