mas ellyx,,
saya mau tanya,, data saya tidak tersimpan ke database walau tidak ada pesan errornya
ini coding saya ;
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
if ($_POST) {
$nip = $_POST['nip'];
$nuptk = $_POST['nuptk'];
$nama = $_POST['nama'];
$jabatan = $_POST['jabatan'];
$tmp_tugas = $_POST['tmp_tugas'];
$golongan = $_POST['golongan'];
$alamat = $_POST['alamat'];
$tmp_lahir = $_POST['tmp_lahir'];
$tgl_lahir = $_POST['l_tanggal'].$_POST['l_bulan'].$_POST['l_tahun'];
$tmt_cpns = $_POST['t_tanggal'].$_POST['t_bulan'].$_POST['t_tahun'];
$tmt_pns = $_POST['tm_tanggal'].$_POST['tm_bulan'].$_POST['tm_tahun'];
$tmt_gol = $_POST['tmt_tanggal'].$_POST['tmt_bulan'].$_POST['tmt_tahun'];
$pendidikan = $_POST['pendidikan'];
$jurusan = $_POST['jurusan'];
$status[0] = "PNS";
$status[1] = "CPNS";
$error = array();
if (empty($nip)) {
$error['nip'] = 'NIP tidak boleh kosong !'; }
if (empty($nuptk)) {
$error['nuptk'] = 'NUPTK tidak boleh kosong !'; }
if (empty($nama)) {
$error['nama'] = 'Nama tidak boleh kosong !'; }
if (empty($jabatan)) {
$error['jabatan'] = 'Jabatan belum di pilih !'; }
if (empty($tmp_tugas)) {
$error['tmp_tugas'] = 'Tempat tugas tidak boleh kosong !'; }
if (empty($golongan)) {
$error['golongan'] = 'Golongan belum di pilih !'; }
if (empty($alamat)) {
$error['alamat'] = 'Alamat tidak boleh kosong !'; }
if (empty($tmp_lahir)) {
$error['tmp_lahir'] = 'Tempat lahir harus di isi !'; }
if (empty($tmt_pns)) {
$st_peg=$status[1]; }
else {
$st_peg=$status[0]; }
if (empty($pendidikan)) {
$error['pendidikan'] = 'Belum memilih Pendidikan !'; }
else {
if ($pendidikan == "D2"||"D3"||"S1"||"S2"||"S3" AND(empty($jurusan))) {
$error['jurusan'] = 'Jurusan harus di input !'; }
}
if (empty($error)) {
//koneksi ke database
include 'sambung.php';
//menyimpan data ke database
$q = "insert into pegawai set nip='$nip',nuptk='$nuptk',nama='$nama',jabatan='$jabatan',golongan='$golongan',alamat='$alamat',tmp_lahir='$tmp_lahir',tgl_lahir='$tgl_lahir',tmt_cpns='$tmt_cpns',tmt_pns='$tmt_pns',status_pegawai='$st_peg',tmt_golongan='$tmt_gol',tmp_tugas='$tmp_tugas',pendidikan='$pendidikan / $jurusan'";
$simpan = mysql_query ($q);
if ($simpan) {
header("location: data_pns.php"); }
else {
echo "Error, Penyimpanan gagal !".mysql_error();
}
}
}
?>
<html>
<head>
</head>
<body>
<?php
echo '<div style="width:1080px">';
include 'header-menu.php';
echo '</div>'; ?>
<table align="center">
<form id="formPNS" name="formPNS" method="post" action="">
<?php
$jab = array("Kepala Sekolah","Guru","Tata Usaha","Staff TU","Pustakawan","Staff Lab","Penjaga Sekolah");
$jx= "<select name='jabatan' id='jabatan'>";
$jx.= "<option value=''>[none]</option>";
foreach($jab as $key)
$jx.= "<option value='$key'>$key</option>";
$jx.= "</select> <br />";
?>
<?php
$gol = array("Juru Muda/I-A","Juru Muda/I-B","Juru Muda/I-C","Juru Muda/I-D","Pengatur Muda Tk.1/II-A","Pengatur Muda Tk.1/II-B","Pengatur Muda Tk.1/II-C","Pengatur Muda Tk.1/II-D","Penata Tk.1/III-A","Penata Tk.1/III-B","Penata Tk.1/III-C","Penata Tk.1/III-D","Pembina/IV-A","Pembina/IV-B","Pembina/IV-C","Pembina/IV-D");
$gx= "<select name='golongan' id='golongan'>";
$gx.= "<option value=''>[none]</option>";
foreach($gol as $key)
$gx.= "<option value='$key'>$key</option>";
$gx.= "</select> <br />";
?>
<?php
$pend = array("SD","SLTP","SLTA","D1","D2","D3","S1","S2","S3");
$px= "<select name='pendidikan' id='pendidikan' onChange='showForm(this.value)'>";
$px.= "<option value=''>[none]</option>";
foreach($pend as $key)
$px.= "<option value='$key'>$key</option>";
$px.= "</select> <br />";
?>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>NIP</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px"><input name="nip" id="nip" type="text" size="30" value="<?php echo isset($_POST['nip']) ? $_POST['nip'] : '';?>"/>
<div style="color:red"><?php echo isset($error['nip']) ? $error['nip'] : '';?></div></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>NUPTK</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px"><input name="nuptk" id="nuptk" type="text" size="30" value="<?php echo isset($_POST['nuptk']) ? $_POST['nuptk'] : '';?>"/>
<div style="color:red"><?php echo isset($error['nuptk']) ? $error['nuptk'] : '';?></div></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>Nama</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px"><input name="nama" id="nama" type="text" size="50" value="<?php echo isset($_POST['nama']) ? $_POST['nama'] : '';?>"/>
<div style="color:red"><?php echo isset($error['nama']) ? $error['nama'] : '';?></div></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>Jabatan</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px"><?php echo $jx;?>
<div style="color:red"><?php echo isset($error['jabatan']) ? $error['jabatan'] : '';?></div></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>Tempat Tugas</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px"><input name="tmp_tugas" id="tmp_tugas" type="text" size="50" value="<?php echo isset($_POST['tmp_tugas']) ? $_POST['tmp_tugas'] : '';?>"/>
<div style="color:red"><?php echo isset($error['tmp_tugas']) ? $error['tmp_tugas'] : '';?></div></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>Golongan</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px"><?php echo $gx;?>
<div style="color:red"><?php echo isset($error['golongan']) ? $error['golongan'] : '';?></div></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>Alamat</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px"><input name="alamat" id="alamat" type="text" size="75" value="<?php echo isset($_POST['alamat']) ? $_POST['alamat'] : '';?>"/>
<div style="color:red"><?php echo isset($error['alamat']) ? $error['alamat'] : '';?></div></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>Tempat Lahir</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px"><input name="tmp_lahir" id="tmp_lahir" type="text" size="30" value="<?php echo isset($_POST['tmp_lahir']) ? $_POST['tmp_lahir'] : '';?>" />
<div style="color:red"><?php echo isset($error['tmp_lahir']) ? $error['tmp_lahir'] : '';?></div></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>Tanggal Lahir</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px">
<select name="l_tanggal" id="l_tanggal">
<option value=''>[Tanggal]</option><?php for($i=1;$i<32;$i++){?><option value="<?=$i;?>"><?=$i;?></option><?php }?>
</select> /
<select name="l_bulan" id="l_bulan">
<option value=''>[Bulan]</option>
<option value='Januari'>Januari</option>
<option value='Februari'>Februari</option>
<option value='Maret'>Maret</option>
<option value='April'>April</option>
<option value='Mei'>Mei</option>
<option value='Juni'>Juni</option>
<option value='Juli'>Juli</option>
<option value='Agustus'>Agustus</option>
<option value='September'>September</option>
<option value='Oktober'>Oktober</option>
<option value='November'>November</option>
<option value='Desember'>Desember</option>
</select> /
<select name="l_tahun" id="l_tahun">
<option value=''>[Tahun]</option><?php for($i=1945;$i<=2020;$i++) {?><option value="<?=$i;?>"><?=$i;?></option><?php }?></select></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>TMT CPNS</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px">
<select name="t_tanggal" id="t_tanggal">
<option value=''>[Tanggal]</option><?php for($i=1;$i<32;$i++){?><option value="<?=$i;?>"><?=$i;?></option><?php }?>
</select> /
<select name="t_bulan" id="t_bulan">
<option value=''>[Bulan]</option>
<option value='Januari'>Januari</option>
<option value='Februari'>Februari</option>
<option value='Maret'>Maret</option>
<option value='April'>April</option>
<option value='Mei'>Mei</option>
<option value='Juni'>Juni</option>
<option value='Juli'>Juli</option>
<option value='Agustus'>Agustus</option>
<option value='September'>September</option>
<option value='Oktober'>Oktober</option>
<option value='November'>November</option>
<option value='Desember'>Desember</option>
</select> /
<select name="t_tahun" id="t_tahun">
<option value=''>[Tahun]</option><?php for($i=1945;$i<=2020;$i++) {?><option value="<?=$i;?>"><?=$i;?></option>
<?php }?></select></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>TMT PNS</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px">
<select name="tm_tanggal" id="tm_tanggal">
<option value=''>[Tanggal]</option><?php for($i=1;$i<32;$i++){?><option value="<?=$i;?>"><?=$i;?></option><?php }?>
</select> /
<select name="tm_bulan" id="tm_bulan">
<option value=''>[Bulan]</option>
<option value='Januari'>Januari</option>
<option value='Februari'>Februari</option>
<option value='Maret'>Maret</option>
<option value='April'>April</option>
<option value='Mei'>Mei</option>
<option value='Juni'>Juni</option>
<option value='Juli'>Juli</option>
<option value='Agustus'>Agustus</option>
<option value='September'>September</option>
<option value='Oktober'>Oktober</option>
<option value='November'>November</option>
<option value='Desember'>Desember</option>
</select> /
<select name="tm_tahun" id="tm_tahun">
<option value=''>[Tahun]</option><?php for($i=1945;$i<=2020;$i++) {?><option value="<?=$i;?>"><?=$i;?></option>
<?php }?></select></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>TMT Golongan</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px">
<select name="tmt_tanggal" id="tmt_tanggal">
<option value='0'>[Tanggal]</option><?php for($i=1;$i<32;$i++){?><option value="<?=$i;?>"><?=$i;?></option><?php }?>
</select> /
<select name="tmt_bulan" id="tmt_bulan">
<option value=''>[Bulan]</option>
<option value='Januari'>Januari</option>
<option value='Februari'>Februari</option>
<option value='Maret'>Maret</option>
<option value='April'>April</option>
<option value='Mei'>Mei</option>
<option value='Juni'>Juni</option>
<option value='Juli'>Juli</option>
<option value='Agustus'>Agustus</option>
<option value='September'>September</option>
<option value='Oktober'>Oktober</option>
<option value='November'>November</option>
<option value='Desember'>Desember</option>
</select> /
<select name="tmt_tahun" id="tmt_tahun">
<option value='0'>[Tahun]</option><?php for($i=1945;$i<=2020;$i++) {?><option value="<?=$i;?>"><?=$i;?></option>
<?php }?></select></td>
</tr>
<tr>
<td style="padding-left:20px; padding-top:10px"><b>Pendidikan Terakhir</b></td>
<td style="padding-left:20px; padding-top:10px"><b>:</b></td>
<td style="padding-left:20px; padding-top:10px"><?php echo $px;?>
<div id="D2" style="display:none">
<p>Masukkan Jurusan<br /><input type="text" name="jurusan" id="jurusan" /></p>
</div>
<div id="D3" style="display:none">
<p>Masukkan Jurusan<br /><input type="text" name="jurusan" id="jurusan" /></p>
</div>
<div id="S1" style="display:none">
<p>Masukkan Jurusan<br /><input type="text" name="jurusan" id="jurusan" /></p>
</div>
<div id="S1" style="display:none">
<p>Masukkan Jurusan<br /><input type="text" name="jurusan" id="jurusan" /></p>
</div>
<div id="S3" style="display:none">
<p>Masukkan Jurusan<br /><input type="text" name="jurusan" id="jurusan" /></p>
</div>
<script type="text/javascript">
function showForm(id){
document.getElementById('D2').style.display='none';
document.getElementById('D3').style.display='none';
document.getElementById('S1').style.display='none';
document.getElementById('S2').style.display='none';
document.getElementById('S3').style.display='none';
document.getElementById(id).style.display='block'; }
</script>
<div style="color:red"><?php echo isset($error['pendidikan']) ? $error['pendidikan'] : '';?></div></td>
</tr>
<tr>
<td style="padding-left:20px"><br /><input type="submit" name="simpan" value="simpan" /></td>
<td colspan="2"><br><input type="reset" name="batal" value="batal" /></td>
</tr>
</form>
</table>
</body>
</html>