<?php
include "connect.php";
$status= "AKTIF";
$nim= $_COOKIE['nim'];
$namamhs=$_COOKIE['namamhs'];
$tingkat=$_COOKIE['tingkat'];
$kelas=$_COOKIE['kelas'];
$semester= $_COOKIE['semester'];
$ta = $_COOKIE['ta'];
$cek = mysqli_query($koneksi,"select * from krs where nim='$nim' AND semester='$semester'AND ta='$ta'");
$hasil=mysqli_num_rows($cek);
if($hasil>0)
{
die("sudah pernah input <a href=fkrsmhs.php>close</a>");
}
echo"<table>";

foreach($_POST['kd_mtk'] as $i => $kd_mtk){
	$jsks = $_POST['jsks'][$i];
 mysqli_query($koneksi,"insert into krs (nim,kd_mtk,semester,ta,jsks) values ('$nim','$kd_mtk','$semester','$ta','$jsks')");
 mysqli_query($koneksi,"update mhs set status='$status' where nim='$nim'");
 } 
echo "$namamhs Berhasil Registrasi... <a href=fkrsmhs.php>close</a>"
?>