<?php
require("../../config/koneksi.php");
require("../../config/function.php");
require("../../config/crud.php");

(isset($_GET['pg'])) ? $pg = $_GET['pg'] : $pg = '';
if ($pg == 'hapus') {
    $id = $_POST['id'];
    delete($koneksi, 'penabung', ['idsiswa' => $id]);
	delete($koneksi, 'tabungan', ['idsiswa' => $id]);
}  


if ($pg == 'tambah') {
    if($_POST['id_siswa']<>''){
        $data = [
        'id_tab'     => $_POST['idtab'],
        'nama'         => $_POST['nama'],
        'idsiswa'     => $_POST['id_siswa'],
        'kelas'   => $_POST['id_kelas'],
        'nama'         => str_replace("'", "&#39;", $_POST['nama']),
        'wa'     => $_POST['hp']
      
    ];
   $datax=[
   'hp'=>$_POST['hp']
   ];
   
            $exec = insert($koneksi, 'penabung', $data);
			$exec = update($koneksi, 'siswa', $datax,['id_siswa' => $_POST['id_siswa']]);
            echo "OK";
        }else{
}
}
  