<LINK href="../images/index.css" rel="stylesheet" type="text/css">
<?PHP
//$i_tgl1=date("d/m/Y");
$do1 = $_POST["do"];
$id1 = $_POST["id"];
$agenda1 = $_POST["agenda"];
$tglskk1 = $_POST["tglskk"];
$noskk1 = $_POST["noskk"];
$skkdengan1 = $_POST["skkdengan"];
$skktentang1 = $_POST["skktentang"];
if ($do1 == "post"){
$error = "";
if ($tglskk1 == ""){$error = "TGL MOU TIDAK BOLEH KOSONG<BR>";}
if ($noskk1 == ""){$error = "NO MOU TIDAK BOLEH KOSONG<BR>";}
if ($skkdengan1  == ""){$error = "MOU DENGAN TIDAK BOLEH KOSONG<BR>";}
if ($skktentang1 == ""){$error = "MOU TENTANG TIDAK BOLEH KOSONG<BR>";}
include("index.db.php");
$mytable = "skk";
$query = "Select * from $mytable where d_agenda = '$agenda1'";
$result = mysql_query($query); 
if ($row = mysql_fetch_array($result)){ 
if  ($row["d_agenda"] == $agenda1){$error = "$error TIDAK BOLEH ADA DUPLIKASI/NOMOR AGENDA GANDA YAITU NO AGENDA : $agenda1'<br><br>SOLUSI : REFRESH / LOGOUT TERLEBIH DAHULU\n";}
}
if ($error == ""){
$query = "INSERT INTO skk (d_tgl, d_agenda, d_noskk, d_pemberikuasa, d_kuasatentang) VALUES ('$tglskk1','$agenda1','$noskk1','$skkdengan1','$skktentang1')";
$result = mysql_query($query);
print ('<table width="100%"  border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td><table width="100%"  border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td><a href="../index.page.php?g=skk&d=inc" class="menudatun">PENAMBAHAN SKK BERHASIL DISIMPAN KLIK UNTUK KEMBALI<a></td>
      </tr>
    </table></td>
  </tr>
</table>');

}
else
{
echo "$error.";
} 
//---------------
}
//next
if ($do1 == "edit"){
include("index.db.php");
$mytable = "skk";
$query = "UPDATE $mytable SET d_tgl = '$tglskk1', d_agenda = '$agenda1', d_noskk = '$noskk1', d_pemberikuasa = '$skkdengan1', d_kuasatentang = '$skktentang1' WHERE d_id = '$id1'"; //UNTUK PENYETINGAN SEMENTARA JIKA SUDAH BERI TANDA //
$result = mysql_query($query);
print ('<table width="100%"  border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td><table width="100%"  border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td><a href="../index.page.php?g=skk&d=inc" class="menudatun">EDIT SKK BERHASIL DISIMPAN KLIK UNTUK KEMBALI<a></td>
      </tr>
    </table></td>
  </tr>
</table>');
}
$del1 = $_GET["do"];
$id1 = $_GET["id"];
if ($del1 == "del"){
include("index.db.php");
$mytable = "skk";
// Create connection
$conn = new mysqli($server, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// sql to delete a record
$sql = "DELETE FROM $mytable WHERE d_id = '$id1'";

if ($conn->query($sql) === TRUE) {
    echo "<a href=\"../index.page.php?g=skk&d=inc\" class=\"menu\">BERHASIL MENGHAPUS  KLIK UNTUK KEMBALI</a>";
} else {
    echo "Error deleting record: " . $conn->error;
}

$conn->close();
}
?>

