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

$tklp       = $_POST['t2digit'];
$tsub       = $_POST['t3digit'];
$tnama      = $_POST['tnama_akunt'];

$sql2 = mysqli_query($koneksi, "SELECT noperk FROM nawal WHERE nosub='$tsub' ORDER BY noperk DESC LIMIT 1");
                list($noperk) = mysqli_fetch_array($sql2);
$kd_ke=$noperk+1 ;
$tkd=$tsub.$kd_ke ;

    $query = mysqli_query($mysqli, "INSERT INTO nawal (noperk,perk,klp,nosub) 
                                    VALUES('$kd_ke','$tnama','$tklp','$tsub')")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                    
header("location:kode_akunt.php?kd2=$tklp&kd3=1");