
<?php
include("../index.cma.db.php");
mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$key1 = $_POST['key'];
$table1 = $_POST['table'];
$kejati1 = $_POST['kejati'];
$kejari1 = $_POST['kejari'];
$tipe1 = $_POST['tipe'];
$alamat1 = $_POST['alamat'];
$nosms1 = $_POST['nosms'];
$camelonid1 = $_POST['camelonid'];
$camelonkey1 = $_POST['camelonkey'];
//----------STEP
if ($key1 == "lokasi"){
$query = "UPDATE $table1 Set s_wil = '$kejati1' where s_id = '1'";  
$result = mysql_query($query); 
$query = "UPDATE $table1 Set s_satker = '$kejari1' where s_id = '1'";  
$result = mysql_query($query); 
$query = "UPDATE $table1 Set s_tipe = '$tipe1' where s_id = '1'";  
$result = mysql_query($query); 
$query = "UPDATE $table1 Set s_alamat = '$alamat1' where s_id = '1'";  
$result = mysql_query($query); 
$query = "UPDATE $table1 Set s_sms = '$nosms1' where s_id = '1'";  
$result = mysql_query($query); 
$query = "UPDATE $table1 Set camelon_id = '$camelonid1' where s_id = '1'";  
$result = mysql_query($query); 
$query = "UPDATE $table1 Set camelon_key = '$camelonkey1' where s_id = '1'";  
$result = mysql_query($query); 
echo "<b>BERHASIL MENYIMPAN PENGATURAN ANDA  <a href=\"index.php?g=pengaturan&i=index\">KLIK DISINI UNTUK KEMBALI</a></b>";
}
//----------STEP
if ($key1 == "dbperkara"){
$dbperkara1 = $_POST['dbperkara1'];
$dbperkara2 = "$dbperkara1";
$dbperkaratahun = substr($dbperkara2,15,4);
$query = "UPDATE $table1 Set t_table = '$dbperkara1' where t_id = '1'";  
$result = mysql_query($query); 
$query = "UPDATE $table1 Set t_tahun = '$dbperkaratahun' where t_id = '1'";  
$result = mysql_query($query); 
echo "<b>BERHASIL MENYIMPAN PENGATURAN ANDA  <a href=\"index.php?g=pengaturan&i=index\">KLIK DISINI UNTUK KEMBALI</a></b>";
}
//----------STEP
if ($key1 == "persuratan"){
$dbpersuratan1 = $_POST['dbpersuratan1'];
$dbpersuratan2 = "$dbpersuratan1";
$dbpersuratantahun = substr($dbpersuratan2,9,4);
$query = "UPDATE $table1 Set s_nama = '$dbpersuratan1' where s_id = '1'";  
$result = mysql_query($query); 
$query = "UPDATE $table1 Set s_tahun = '$dbpersuratantahun' where s_id = '1'";  
$result = mysql_query($query); 
echo "<b>BERHASIL MENYIMPAN PENGATURAN ANDA  <a href=\"index.php?g=pengaturan&i=index\">KLIK DISINI UNTUK KEMBALI</a></b>";
}
//----------STEP
if ($key1 == "barbuk"){
include("../barbuk/index.db.php");
$dbbarbuk1 = $_POST['barbuk_db1'];
$dbbarbuktahun1 = substr($dbbarbuk1,6,4);
$query = "UPDATE barbuk_db Set t_table = '$dbbarbuk1' where t_id = '1'";  
$result = mysql_query($query); 
$query = "UPDATE barbuk_db Set t_tahun = '$dbbarbuktahun1' where t_id = '1'";  
$result = mysql_query($query); 
echo "<b>BERHASIL MENYIMPAN PENGATURAN DATABASE BARANG BUKTI ANDA  <a href=\"index.php?g=pengaturan&i=index\">KLIK DISINI UNTUK KEMBALI</a></b>";
}
//----------STEP
if ($key1 == "polisi"){
$instansi2 = $_POST['instansi'];
$nourut2 = $_POST['nourut'];
$error = "";
//START pengecekan jika form kosong
if ($instansi2 == ""){$error = "$error<li>INSTANSI BELUM DI INPUT<BR>\n";}
if ($nourut2== ""){$error = "$error<li>NO URUT BELUM DI INPUT DAN TIDAK BOLEH SAMA<BR>\n";}
    if($key1 !== "polisi") {
      echo '<font color="red"><b>PENDAFTARAN KAMI TOLAK! KEY SALAH</b></font>';
    }
	elseif($nourut2 == "") {
      echo '<font color="red"><b>NO URUT TIDAK BOLEH KOSONG SILAHKAN ULANGI</b></font>';
    }
	//jika sesi dan image benar maka dilanjutkan posting
    else {
include("../index.cma.db.php");
mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$query = "Select * from $table1 where p_nomor = '$nourut2'";
$result = mysql_query($query); 
if ($row = mysql_fetch_array($result)){ 
if  ($row["p_nomor"] == $nourut2){$error = "$error<li>NOMOR URUT SUDAH TERDAFTAR. TIDAK BOLEH SAMA, DAN DI EDIT"; }
//if  ($row["j_nama"] == $nama1){$error = "$error<li>Nama Anda sudah pernah terdaftar<br>\n";}
}
//END
if ($error == ""){
$query = "INSERT INTO $table1 (p_nama, p_nomor) VALUES ('$instansi2','$nourut2')";
$result = mysql_query($query);
echo "<b>BERHASIL INPUT DATA KEPOLISIAN <a href=\"index.php?g=pengaturan&i=index\">KLIK DISINI UNTUK KEMBALI</a></b>";
}
else
{
echo "<br>$error. GAGAL MEMPOSTING <a href=\"index.php?g=pengaturan&i=index\">KLIK DISINI UNTUK KEMBALI</a>";
} 
?>
<?
}}
?>
