<!-- basic form start -->
<div class="col-12 mt-5">
	<div class="card">
		<div class="card-body">
			<h4 class="header-title">Tambah Data Kelas Siswa</h4>
			<form method="post" enctype="multipart/form-data">
				<div class="form-group">
					<?php
# Opsi Level Login
					$arrLevel	= array("Kasir","Admin");

					if($_GET) {
						if(isset($_POST['btnSave'])){
							$message = array();
							if (trim($_POST['txtnis'])=="") {
								$message[] = "NIS tidak boleh kosong !";		
							}
							if (trim($_POST['txtkdkelas'])=="") {
								$message[] = "Kode kelas tidak boleh kosong !";		
							}


		# Baca Variabel Form
							$txtkdkelas	= $_POST['txtkdkelas'];
							$txtkdkelas	= str_replace("'","&acute;",$txtkdkelas);

							$txtnis	= $_POST['txtnis'];
							$txtnis= str_replace("'","&acute;",$txtnis);





		# Jika jumlah error message tidak ada
							if(count($message)==0){			
								$sqlSave="INSERT INTO kelas_siswa SET nis='$txtnis', kdkelas='$txtkdkelas'";
								$qrySave=mysql_query($sqlSave, $koneksidb) or die ("Gagal query".mysql_error());
								if($qrySave){
									echo "<meta http-equiv='refresh' content='0; url=?page=Data-Kelas-Siswa&Act=Sucsses'>";
								}
							}	

		# JIKA ADA PESAN ERROR DARI VALIDASI
		// (Form Kosong, atau Duplikat ada), Ditampilkan lewat kode ini
							if (! count($message)==0 ){
								echo "<div class='mssgBox'>";
								// echo "<img src='images/attention.png' class='imgBox'> <hr>";
								$Num=0;
								foreach ($message as $indeks=>$pesan_tampil) { 
									$Num++;
									echo "<div class='alert alert-danger alert-dismissible fade show' role='alert'>";
									echo "&nbsp;&nbsp; $Num. $pesan_tampil<br>";
									echo "<button type='button' class='close' data-dismiss='alert' aria-label='Close'>";
									echo "<span class='fa fa-times'></span>
									</button>
									</div>";	
								} 
								echo "</div>"; 
							}
	} // Penutup POST
	
	# MASUKKAN DATA KE VARIABEL
	$datanis= isset($_POST['txtnis']) ? $_POST['txtnis'] : '';
	$datakdkelas= isset($_POST['txtkdkelas']) ? $_POST['txtkdkelas'] : '';
	
	
} // Penutup GET
?>
</div>
<div class="form-row">
	<div class="col-md-6 mb-3">
		<label for=""><b>NIS</b></label>
		<input type="text" class="form-control" name="txtnis" value="<?php echo $datanis; ?>" placeholder="Masukan NIS">
	</div>
	<div class="col-md-6 mb-3">
		<label for=""><b>Kode Kelas</b></label>
		<input type="text" class="form-control" name="txtkdkelas" value="<?php echo $datakdkelas; ?>" placeholder="Masukan Kode Kelas">
	</div>
</div>
<button type="submit" class="btn btn-primary col-12" name="btnSave"><b>Simpan Data</b></button>
</form>
</div>
</div>
</div>
<!-- basic form end -->