<?php 
include '../koneksi.php';
$id          = $_POST['id'];
$xnama       = $_POST['xnama_e'];
$xusername   = $_POST['xusername_e'];

$xlevel      = $_POST['xlevel_e'];

if ($xlevel=='PDL') {
    $xkdr        = $_POST['xkdr'];    
} else {
    $xkdr        = '';
}

// cek gambar
$rand = rand();
$allowed =  array('gif','png','jpg','jpeg');
$filename = basename($_FILES['foto']['name']);
$ext = pathinfo($filename, PATHINFO_EXTENSION);

if(!in_array($ext,$ekstensi) ) {
        mysqli_query($koneksi, "update user set user_nama='$xnama',user_username='$xusername',user_level='$xlevel',user_kdr='$xkdr' where user_id='$id'");
        header("location:a_user.php");
}else{
	if($ukuran < 1044070){		
		$xx = $rand.'_'.$filename;
		move_uploaded_file($_FILES['foto']['tmp_name'], '../gambar/'.$rand.'_'.$filename);
        mysqli_query($koneksi, "update user set user_nama='$xnama',user_username='$xusername',user_level='$xlevel',user_kdr='$xkdr',user_foto='$xx' where user_id='$id'");
		header("location:a_user.php?alert=berhasil");
	}else{
		header("location:index.php?alert=gagak_ukuran");
	}
}
