<?php 
include '../koneksi.php';
$tsub       = $_POST['tsub'];
$tnama      = $_POST['tnama'];

$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,nosub) 
                                    VALUES('$kd_ke','$tnama','$tsub')")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                    
header("location:kode_akunt.php?kd2=11&kd3=1");