<?php
include('assets/inc/config.php');

if ($_POST) {
    $email = $_POST['email'];
    $password = $_POST['password'];
    $password = md5($password);

    $chkUser = "SELECT * FROM `tbl_register` where `email` = '$email' and `password` = '$password' and status = 'active'";
    $result = mysqli_query($conn, $chkUser);
    if (mysqli_num_rows($result) > 0) {
        $row = mysqli_fetch_assoc($result);
        $userId = $row['id'];
        $userRole = $row['role'];
        $first_name = $row['first_name'];
        $last_name = $row['last_name'];
        $username = $first_name . $last_name;

        $_SESSION['USER_ID'] = $userId;
        $_SESSION['USER_ROLE'] = $userRole;
        $_SESSION['USER_NAME'] = $username;

        echo $userRole;
    } else {
        echo 0;
    }
} else {
}
