<?php
session_start();
require_once "../config/koneksi.php";

    $username = $_POST['user1'];
    $userpass = $_POST['pass1'];
    $tahun = $_POST['tahun']; // password yang di inputkan oleh user lewat form login.
    $sql = "SELECT a.user1, a.password1, a.halaman,a.id_admin,a.id_opd,b.opd, b.kode_skpd FROM admin as a inner join opd as b on a.id_opd=b.id_opd  WHERE a.user1 = '$username'";
    $result=mysqli_query($koneksi, $sql);
    list($username, $password, $halaman,$id_admin,$id_opd,$opd,$kode_skpd) = mysqli_fetch_array($result);
     if (mysqli_num_rows($result) > 0) {
        if (password_verify($userpass, $password)) {
            $_SESSION['user1'] = $username;
            $_SESSION['halaman'] = $halaman;
            $_SESSION['id_admin'] = $id_admin;
            $_SESSION['id_opd'] = $id_opd;
            $_SESSION['opd'] = $opd;
            $_SESSION['tahun'] = $tahun;
            $_SESSION['kode_sub_skpd'] = $kode_skpd;
            header("location:halaman.php");
        } else {
           header("location: ../login?pasword=User Atau Pasword Salah");
        }
   } else
        {
        header("location: ../login?pasword=User Atau Pasword Salah");  
        }
?>