
<?php 
    include '../koneksi.php';

    $tnama      = $_POST['nama'];
    $tno_klp     = $_POST['no_klp'];
    
    $teks_kapital = strtoupper($tnama);


              // fungsi membuat NOPERK
              $kaw = mysqli_query($koneksi, "SELECT kd2 as kode3 FROM n_kode_3 WHERE kd1='$tno_klp' ORDER BY kd2 DESC LIMIT 1");
                list($kode3) = mysqli_fetch_array($kaw);
              $count3 = mysqli_num_rows($kaw);

              if ($count3 <> 0) {
                  $data_id3 = mysqli_fetch_assoc($kaw);
                  $kode4    = $kode3+1;
              } else {
                  $kode4    = '1';
              }
              $no=$tno_klp.$kode4 ;
              
    /////////// 
    $query = mysqli_query($mysqli, "INSERT INTO n_kode_3 (kd,kd1,kd2,nama) 
                                    VALUES('$no','$tno_klp','$kode4','$teks_kapital')")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                    
    header("location:kode_akunt_new_sub.php");
?>