Postingan lainnya
Tidak dapat insert data ke databases
<?php
session_start();
include 'conn.php';
if($_SESSION['stat_login'] != true){
echo '<script>window.location="login.php"</script>';
if(isset($_POST['submit'])){
//proses simpan
$insert = mysqli_query($conn, "INSERT INTO tb_jadwal VALUES (
'".$_POST['id_mapel']."',
'".$_POST['tanggal']."',
'".$_POST['mapel']."',
'".$_POST['keterangan']."',
'".$_POST['pembimbing']."'
)");
if($insert){
echo 'Mata Pelajaran Berhasil Ditambah';
}else{
echo 'Gagal Mendaftar'.mysqli_error($conn);
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Pendaftaran Diklat | Administrator</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@500&display=swap" rel="stylesheet">
</head>
<body>
<!--header-->
<header>
<h1><a href="beranda.php">Admin Pendaftaran Diklat</a></h1>
<ul>
<li><a href="beranda.php">Beranda</a></li>
<li><a href="dt_peserta.php">Data Peserta</a></li>
<li><a href="jadwal.php">Penjadwalan</a></li>
<li><a href="keluar.php">Keluar</a></li>
</ul>
</header>
<!--content-->
<!--box formulir-->
<section class="box-formulir">
<h2>Penjadwalan Peserta Diklat BDK Semarang</h2>
<!--form-->
<form action="" method="POST">
<div class="box">
<table border="0" class="table-form">
<tr>
<td>ID Mapel</td>
<td>:</td>
<td>
<select class="input-control" name="id_mapel" id="id_mapel" onchange="changeValueMapel(this.value)">
<option value="">--Pilih--</option>
<option>
<?php
$sql= mysqli_query($conn,"SELECT * FROM tb_mapel");
$jsArray = "var dtMapel = new Array();\n";
while ($data=mysqli_fetch_array($sql)) {
echo '<option value="'.$data['id_mapel'].'">'.$data['id_mapel'].'</option> ';
$jsArray .= "dtMapel['" . $data['id_mapel'] . "'] = {mapel:'" . addslashes($data['mapel']) . "'};\n";
}
?>
</option>
</select>
</td>
</tr>
<tr>
<td>Tanggal</td>
<td>:</td>
<td>
<input type="date" name="tanggal" class="input-control">
</td>
</tr>
<tr>
<td>Mata Pelajaran</td>
<td>:</td>
<td>
<input type="text" name="mapel" id="mapel" class="input-control">
</td>
</tr>
<tr>
<td>Keterangan</td>
<td>:</td>
<td>
<textarea class="input-control" name="keterangan" ></textarea>
</td>
</tr>
<tr>
<td>Pembimbing</td>
<td>:</td>
<td>
<input type="text" name="pembimbing" class="input-control">
</td>
</tr>
<td></td>
<td></td>
<td>
<input type="submit" name="submit" class="btn-daftar" value="Simpan">
</td>
</tr>
</table>
</div>
</form>
</section>
<script type="text/javascript">
<?php echo $jsArray; ?>
function changeValueMapel(x){
document.getElementById('mapel').value = dtMapel[x].mapel;
};
</script>
</body>
</html>
0
Tanggapan
apakah ada yang ada error yang muncul, jika ada error apa errornya.
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban