<?php 
include '../koneksi.php';
session_start();
$id_angg    = $_POST['tid'];
$nama       = $_POST['tnama'];
$alamat     = $_POST['talamat'];
$tempat     = $_POST['ttempat'];
$umur       = $_POST['tumur'];
$ktp        = $_POST['tktp'];
$kk         = $_POST['tkk'];

$suami      = $_POST['tsuami'];
$sebagai    = $_POST['tsebagai'];
$jekel      = $_POST['tjekel'];
$pekerjaan  = $_POST['tpekerjaan'];
$marital    = $_POST['tmarital'];

$kd_kec     = $_POST['tkd_kec'];
$kd_kab     = $_POST['tkd_kab'];
$tid        = $_POST['tid'];
$tkab       = $_POST['tkab'];
$tkdc       = $_POST['tkdc'];
    $hp     = $_POST['hp'];
    $hp_2   = $_POST['hp_2'];
    
    $rt     = $_POST['rt'];
    $rw     = $_POST['rw'];
    $usaha    = $_POST['xusaha'];
    $kerja    = $_POST['xkerja'];    
    $ktp_a    = $_POST['t_ktp'];
    $kk_a     = $_POST['t_kk'];
    
    $tgl_d = $_POST['tanggal_d'];
    $tgl_s = $_POST['tanggal_s'];    

//    $sql7 = mysqli_query($koneksi, "SELECT id_rw AS tid_rw FROM kd_rt WHERE id='$rtrw' ");
//       list($tid_rw) = mysqli_fetch_array($sql7);
               
    $sql5 = mysqli_query($koneksi, "SELECT kecamatan AS kecam FROM kdkecamatan WHERE kd='$kd_kec' and kdkab='$kd_kab' ");
       list($kecam) = mysqli_fetch_array($sql5); 
       
    $sql6 = mysqli_query($koneksi, "SELECT kabupaten AS kabup FROM kdkabupaten WHERE kd='$kd_kab' ");
       list($kabup) = mysqli_fetch_array($sql6);   

$cek = mysqli_query($koneksi,"select * from anggota where kk='$kk' and kk<>'$kk_a' AND hapus<>'HAPUS' ");
$c = mysqli_num_rows($cek);
if($c == 0){
    
mysqli_query($koneksi, "UPDATE anggota SET jekel='$jekel',nama='$nama',alamat='$alamat',ktp='$ktp',kk='$kk',pekerjaan='$kerja',hp='$hp',usaha='$usaha',rt='$rt',rw='$rw' WHERE angg_id='$id_angg' ")or die(mysqli_errno());

header("location:angg_daftar_jekel.php?jekel<>1&tanggal_d=$tgl_d&tanggal_s=$tgl_s");
}else{
	$siapa = mysqli_fetch_assoc($cek);
	$s = $siapa['angg_nama'];
	$sa = $siapa['angg_alamat'];
	header("location:angg_daftar_jekel.php?jekel<>1&tanggal_d=$tgl_d&tanggal_s=$tgl_s");
}