Advertisement
jamboljack

Update Profil

Oct 3rd, 2018
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 KB | None | 0 0
  1. // Update Profil
  2.     public function updateprofil_post()
  3.     {
  4.         $username      = trim($this->post('username'));
  5.         $nama          = trim($this->post('nama'));
  6.         $tempat_lahir  = trim($this->post('tempat_lahir'));
  7.         $tanggal_lahir = trim($this->post('tanggal_lahir'));
  8.         $alamat        = trim($this->post('alamat'));
  9.         $no_telepon    = trim($this->post('no_telepon'));
  10.         $email         = trim($this->post('email'));
  11.  
  12.         if ($username == '') {
  13.             $response = [
  14.                 'resp_error' => true,
  15.                 'resp_msg'   => 'Username kosong.',
  16.             ];
  17.         } elseif ($nama == '') {
  18.             $response = [
  19.                 'resp_error' => true,
  20.                 'resp_msg'   => 'Nama masih kosong.',
  21.             ];
  22.         } elseif ($tempat_lahir == '') {
  23.             $response = [
  24.                 'resp_error' => true,
  25.                 'resp_msg'   => 'Tempat Lahir masih kosong.',
  26.             ];
  27.         } elseif ($tanggal_lahir == '') {
  28.             $response = [
  29.                 'resp_error' => true,
  30.                 'resp_msg'   => 'Tanggal Lahir masih kosong.',
  31.             ];
  32.         } elseif ($alamat == '') {
  33.             $response = [
  34.                 'resp_error' => true,
  35.                 'resp_msg'   => 'Alamat masih kosong.',
  36.             ];
  37.         } elseif ($no_telepon == '') {
  38.             $response = [
  39.                 'resp_error' => true,
  40.                 'resp_msg'   => 'No. Telepon masih kosong.',
  41.             ];
  42.         } elseif ($email == '') {
  43.             $response = [
  44.                 'resp_error' => true,
  45.                 'resp_msg'   => 'Email masih kosong.',
  46.             ];
  47.         } else {
  48.             $data = array(
  49.                 'user_name'        => strtoupper($nama),
  50.                 'tempat_lahir'     => strtoupper($tempat_lahir),
  51.                 'tanggal_lahir'    => $tanggal_lahir,
  52.                 'alamat_rumah'     => strtoupper(trim($alamat)),
  53.                 'no_telepon'       => trim($no_telepon),
  54.                 'user_email'       => trim($email),
  55.                 'user_date_update' => date('Y-m-d'),
  56.                 'user_time_update' => date('Y-m-d H:i:s'),
  57.             );
  58.  
  59.             $this->db->where('user_username', $username);
  60.             $this->db->update('bpmppt_users', $data);
  61.  
  62.             $response = [
  63.                 'resp_error' => false,
  64.                 'resp_msg'   => 'Profil Update',
  65.             ];
  66.         }
  67.  
  68.         $this->response($response, 200);
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement