<?php
    require_once('session.php');
    $users = $u['user'];
    $akun = $_POST['akun'];
    $no_rek = $_POST['no_rek'];
    $pemilik = $_POST['pemilik'];
    $kode = date('YdmHis');
    $tipe_gambar = array('image/jpg','image/jpeg','image/bmp', 'image/x-png', 'image/png');
    $gbr = $_FILES['image']['name'];
    $ukuran = $_FILES['image']['size'];
    $tipe = $_FILES['image']['type'];
    $error = $_FILES['image']['error'];
    $explode = explode('.',$gbr);
    $extensi  = $explode[count($explode)-1];
    $newname = 'rekening_'.$users.'_'.$kode.'.'.$extensi;
    $upload_dir = "../../upload/";
    $created_date = date('Y-m-d H:i:s');
    if($u['level'] == 'superadmin'){
        if($gbr !=="" && $error == 0){
            if(in_array(strtolower($tipe), $tipe_gambar)){
                move_uploaded_file($_FILES['image']['tmp_name'], $upload_dir . $newname);
                $query = mysqli_query($conn,"INSERT INTO `tb_bank` (`image`, `akun`, `pemilik`, `no_rek`, `status`,`userID`) VALUES ('$newname', '$akun','$pemilik','$no_rek',1,1)") or die(mysqli_error());
                header('location:../bank/?notif=1');
                exit();
            }
            else {
                header('location:../bank/?notif=3');
                exit();
            } 
        }
        else {
            header('location:../bank/?notif=2');
            exit();
        }
    }
?>