<?php

session_start();
include_once 'functions/fungsi.php';
include_once 'connection/koneksi.php';

$username = $_POST["username"];
$password = $_POST["password"];

$res_set = mysqli_query($database, "select * from user where username='$username' and password='$password'");
$res = mysqli_fetch_array($res_set);
if ($res_set->num_rows < 1) {
    redirect('login.php');
    $_SESSION['error'] = TRUE;
} else {
    set_session('role', $res["role"]);
    set_session('id', $res["id"]);
    set_session('first_name', $res["first_name"]);

//    die(get_session('role'));

    $_SESSION['isLogin'] = TRUE;
   // die(get_session('id'));
    redirect('index.php');
}
