<?php 
	// koneksi database
	include "../koneksi.php";

	// menangkap data yang di kirim dari form
	$KODE = $_POST['NIK'];
	$NAMA = $_POST['NAMA'];
	$TGLJOIN = $_POST['TGL_AWAL_KONTRAK'];
	$TGLAKHIR = $_POST['TGL_AKHIR_KONTRAK'];
	$POSISI = $_POST['POSISI_KERJA'];
	$PT = $_POST['PERUSAHAAN'];
	$LOKASI = $_POST['LOKASI_KERJA'];
	$DEPART = $_POST['DEPARTEMENT'];
	$NOID = $_POST['NO_ID'];
	$NOPAJAK = $_POST['NPWP'];
	$T_LAHIR = $_POST['TEMPAT_LAHIR'];
	$TGL_LAHIR = $_POST['TANGGAL_LAHIR'];
	$J_KELAMIN = $_POST['JENIS_KELAMIN'];
	$GOL_DARAH = $_POST['GOL_DARAH'];
	$ALMT = $_POST['ALAMAT'];
	$RT = $_POST['RT'];
	$RW = $_POST['RW'];
	$KEL = $_POST['KEL'];
	$KEC = $_POST['KEC'];
	$KOTA = $_POST['KOTA'];
	$PROVINSI = $_POST['PROVINSI'];
	$KODEPOS = $_POST['KODEPOS'];
	$STSNIKAH = $_POST['STATUSNIKAH'];
	$AGAMA = $_POST['AGAMA'];
	$JLH_ANAK = $_POST['JUMLAH_ANAK'];
	$NOHP = $_POST['HP'];
	$NO_REK = $_POST['NO_REKENING'];
	$NAMA_REK = $_POST['NAMA_REKENING'];
	$NAMABANK = $_POST['BANK'];
	$NAMAIBU = $_POST['NAMA_IBU'];
	$NOKS = $_POST['BPJS_KS'];
	$NOTK = $_POST['BPJS_TK'];
	$MAIL = $_POST['EMAIL'];
	
		$cek = "select * from personal where NO_ID = $NOID";
		$result = mysqli_query($koneksi, $cek);
		if(mysqli_num_rows($result) > 0){
			// $query = mysqli_query($koneksi, "SELECT NIK as NIK, nama as nm, NO_ID as KTP FROM PERSONAL where NO_ID = $NOID");
			$query = mysqli_query($koneksi, "SELECT * FROM personal where NO_ID = $NOID");
			$data = mysqli_fetch_array($query);
			$nikuser = $data['NIK'];
			$namauser = $data['NAMA'];
			$KTP = $data['NO_ID'];
			
			echo '<div class="alert alert-success alert-dismissible fade in" role="alert">
			<button type="button" class="close" data-dismiss="alert" aria-label="Close">
				<span aria-hidden="true">&times;</span>
			</button>
				<strong> Peringatan..! </strong> No KTP <b> '.$KTP.' </b> Sudah Digunakan Oleh : <b> '.$nikuser.' - '.$namauser.'.!</b>
			<br>
			</div>';
			
			echo '<meta http-equiv="refresh" content="10;url=personal Info.php">';
		}else{
			$a=mysqli_query($koneksi,"INSERT INTO personal VALUES ('$KODE','$NAMA','$TGLJOIN',,'$TGLAKHIR','$POSISI','$PT','$LOKASI','$DEPART','$NOID','$ALMTT, $RT/$RW, $KEL, $KEC, $KOTA, $PROVINSI','$KODEPOS','$NOHP','$J_KELAMIN','$GOL_DARAH','$T_LAHIR','$TGL_LAHIR','$STSNIKAH','$AGAMA','$JLH_ANAK','$NO_REK','$NAMA_REK','$NAMABANK','$NAMAIBU','$NOKS','$NOTK','$NOPAJAK','$MAIL','user')")or die(mysqli_error($koneksi));
			
			echo '<div class="alert alert-success alert-dismissible fade in" role="alert">
			<button type="button" class="close" data-dismiss="alert" aria-label="Close">
				<span aria-hidden="true">&times;</span>
			</button>
				<strong> Sukses..!</strong> Data Berhasil Tersimpan.!
			<br>
			</div>';
			
			echo '<meta http-equiv="refresh" content="3;url=personal Info.php">';
		}
?>