<?php 
include '../koneksi.php';
$xkar       = $_POST['xkar'];
$xusername   = $_POST['xusername'];
//$xpassword   = md5($_POST['xpassword']);
$xpassword   = $_POST['xpassword'];
$xlevel      = $_POST['xlevel'];

$hash_baru = password_hash($xpassword, PASSWORD_BCRYPT);

$sql2 = mysqli_query($koneksi, "SELECT nama,kdc FROM karyawan WHERE id='$xkar'");
                list($nama,$kdc) = mysqli_fetch_array($sql2);
                
if ($xlevel=='AOK') {
    $xkdr        = $_POST['xkdr'];    
} else {
    $xkdr        = '';
}
$foto='';
$yt='Y';

    $query = mysqli_query($mysqli, "INSERT INTO user (user_nama,user_username,user_password_hash,user_level,user_kdr,id_kar,kdc) 
                                    VALUES('$nama','$xusername','$hash_baru','$xlevel','$xkdr','$xkar','$kdc')")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
header("location:a_user.php");