<?php

    session_start();
    include_once("../config/Config.php");

    $config = new Config();

    // untuk mengecek data tersebut sudah diset / tidak jika sudah maka bernilai true jika belum maka false
    if (isset($_POST['login'])){
        $username    = stripslashes($_REQUEST['user']); 
        $password_user = stripslashes($_REQUEST['pass']);
        
       
        $query = $config->getData("SELECT * FROM entity__student WHERE student_nisn='" . $username. "' AND student_nis='". $password_user ."'");

        $rows = count($query); 

        if($rows==1){
            foreach ($query as $r) {
                $_SESSION['student_id'] = $r['student_id'];
                $_SESSION['school_id'] = $r['school_id'];
                $_SESSION['student_nisn'] = $r['student_nisn'];
                $_SESSION['student_nis'] = $r['student_nis'];
                $_SESSION['student_name'] = $r['student_name'];
                $_SESSION['gender'] = $r['student_gender'];
                
                      
                
                header ("Location:".$base_url."viewer/dashboard");
            
                  }

       }else{

            header ('Location:'.$base_url.'login/index.php?ps=gagal');
        
              }
            
    } 
?>
