Advertisement
jamboljack

Insert Prestasi

Aug 15th, 2019
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. // Insert Prestasi
  2.     public function saveprestasi_post()
  3.     {
  4.         $username   = trim($this->post('username'));
  5.         $id         = trim($this->post('id')); // Biodata ID
  6.         $event      = trim($this->post('nama_event'));
  7.         $tempat     = trim($this->post('tempat'));
  8.         $tahun      = trim($this->post('tahun'));
  9.         $juara      = trim($this->post('juara'));
  10.         $catatan    = trim($this->post('catatan'));
  11.         $keterangan = trim($this->post('keterangan'));
  12.  
  13.         if ($username == '') {
  14.             $response = [
  15.                 'resp_error' => true,
  16.                 'resp_msg'   => 'Username kosong.',
  17.             ];
  18.         } elseif ($event == '') {
  19.             $response = [
  20.                 'resp_error' => true,
  21.                 'resp_msg'   => 'Nama Event kosong.',
  22.             ];
  23.         } elseif ($tempat == '') {
  24.             $response = [
  25.                 'resp_error' => true,
  26.                 'resp_msg'   => 'Nama Tempat kosong.',
  27.             ];
  28.         } elseif ($tahun == '') {
  29.             $response = [
  30.                 'resp_error' => true,
  31.                 'resp_msg'   => 'Tahun kosong.',
  32.             ];
  33.         } elseif ($juara == '') {
  34.             $response = [
  35.                 'resp_error' => true,
  36.                 'resp_msg'   => 'Juara kosong.',
  37.             ];
  38.         } else {
  39.             $data = array(
  40.                 'biodata_id'          => $id,
  41.                 'prestasi_even'       => strtoupper(trim(stripHTMLtags($event))),
  42.                 'prestasi_tempat'     => strtoupper(trim(stripHTMLtags($tempat))),
  43.                 'prestasi_tahun'      => strtoupper(trim(stripHTMLtags($tahun))),
  44.                 'prestasi_juara'      => strtoupper(trim(stripHTMLtags($juara))),
  45.                 'prestasi_catatan'    => strtoupper(trim(stripHTMLtags($catatan))),
  46.                 'prestasi_keterangan' => strtoupper(trim(stripHTMLtags($keterangan))),
  47.                 'prestasi_update'     => date('Y-m-d H:i:s'),
  48.             );
  49.  
  50.             $this->db->insert('olga_bio_prestasi', $data);
  51.             $response = ['resp_error' => false, 'resp_msg' => 'success'];
  52.         }
  53.  
  54.         $this->response($response, 200);
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement