MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 8.0.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/demo.imensosoftware.com/matrix/login_code.php
<?php 
require_once 'config.php';

if (isset($_POST['login'])) {

    if (!empty($_POST['email']) && !empty($_POST['password'])) {

        $stmt = $conn->prepare("
            SELECT role_user.role_id as role_id, users.* 
            FROM users 
            LEFT JOIN role_user ON users.id = role_user.user_id 
            WHERE users.email = ?
        ");

        $stmt->bind_param("s", $_POST['email']);
        $stmt->execute();
        $result = $stmt->get_result();

        if ($result->num_rows > 0) {

            $row = $result->fetch_assoc();

            if ($row['role_id'] != 1) {

                if (password_verify($_POST['password'], $row['password'])) {

                    $_SESSION['user_id'] = $row['id'];
                    $_SESSION['role_id'] = $row['role_id'];
                    $_SESSION['name'] = $row['name'];

                    header('Location: index.php');
                    exit();

                } else {
                    $_SESSION['error'] = 'Invalid Email or Password!!';
                    header('Location: login.php');
                    exit();
                }

            } else {
                $_SESSION['error'] = 'Unauthorized User!!';
                header('Location: login.php');
                exit();
            }

        } else {
            $_SESSION['error'] = 'Invalid Email or Password!!';
            header('Location: login.php');
            exit();
        }

    } else {
        $_SESSION['error'] = 'Please enter Email and Password';
        header('Location: login.php');
        exit();
    }
}
?>