nebukad

Untitled

Feb 27th, 2014
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.49 KB | None | 0 0
  1. model site_model.php :
  2.    
  3.     // insert data ke database dirubah //
  4.     function tambah_con($data) {
  5.         $this->db->insert('confirm', $data);
  6.     }    
  7.      
  8.     controller home.php :
  9.     // function do_upload diganti ini //
  10.     public function do_upload()
  11.     {
  12.         $config['upload_path'] = "./asset/images/"; //lokasi folder yang akan digunakan untuk menyimpan file
  13.         $config['allowed_types'] = 'gif|jpg|png|JPEG'; //extension yang diperbolehkan untuk diupload
  14.         $config['max_size'] = '1024';
  15.         $config['file_name'] = url_title($this->input->post('file_upload'));
  16.  
  17.         $this->upload->initialize($config); //meng set config yang sudah di atur
  18.         if( !$this->upload->do_upload('file_upload'))
  19.         {
  20.             echo $this->upload->display_errors();
  21.         }
  22.         else{
  23.             $this->session->set_flashdata('message', '<strong>Congratulation,</strong> you have been registered in this programme, We will change your participant status to be confirmation
  24.                                                   and after that we will send your invitation letter at your <strong>Email.</strong>');
  25.             $data = array(
  26.             'name'=>$this->upload->file_name
  27.             );
  28.             $this->site_model->insert($data,'images');
  29.             //redirect('home/add_con');
  30.             return $this->upload->file_name;
  31.         }
  32.     }
  33.    
  34.     // function simpan_con diganti ini //
  35.     function simpan_con() {
  36.         $this->form_validation->set_rules('select1', 'Full Name', 'trim|required');
  37.         $this->form_validation->set_rules('account', 'Account Name', 'trim|required');
  38.         $this->form_validation->set_rules('bank', 'Bank Name', 'trim|required');
  39.         $this->form_validation->set_rules('tanggal', 'Date of make a Payment', 'trim|required');
  40.         $this->form_validation->set_rules('file_upload', 'File Upload', 'trim|required');
  41.         if ($this->form_validation->run() == FALSE) {  
  42.             if ($this->input->post('submit')) {
  43.                  $this->data['select1'] = $this->input->post('select1');
  44.                  $this->data['id_jen'] = $this->input->post('id_jen');
  45.                  $this->data['st'] = $this->input->post('st');
  46.                  $this->data['account'] = $this->input->post('account');
  47.                  $this->data['bank'] = $this->input->post('bank');
  48.                  $this->data['tanggal'] = $this->input->post('tanggal');
  49.                  $this->data['content'] = 'confirm_p';
  50.                  $this->load->view('template', $this->data);
  51.             }
  52.         } else {
  53.             $this->session->set_flashdata('message', '<strong>Congratulation,</strong> you have been registered in this programme, We will change your participant status to be confirmation
  54.                                           and after that we will send your invitation letter at your <strong>Email.</strong>');
  55.             $st = $this->input->post('st');
  56.             if ($this->input->post('submit')) {
  57.                 if (trim($st)=="tambah") {
  58.                     $this->load->model('site_model');
  59.                     $name = $this->input->post('select1');
  60.                     $account = $this->input->post('account');
  61.                     $bank = $this->input->post('bank');
  62.                     $tgl = $this->input->post('tanggal');
  63.                     $upload = $this->do_upload();
  64.                    
  65.                     $data = array('id_jen' => NULL,
  66.                             'name' => $this->input->post('select1');,
  67.                             'acco' => $this->input->post('account'),
  68.                             'bank' => $this->input->post('bank'),
  69.                             'tgl' => $this->input->post('tanggal'),
  70.                             'file' => $upload
  71.                       );
  72.                     $this->site_model->tambah_con($data);
  73.                     redirect('home/add_con');
  74.                 }
  75.                 else if (trim($st)=="edit") {
  76.                     $this->session->set_flashdata('message', 'Selamat, Anda telah berhasil melakukan Registrasi');
  77.                     $id_jenis = $this->input->post('id_jenis');
  78.                     $this->load->model('site_model');
  79.                     $this->site_model->update($id_jenis);
  80.                     redirect('home/table');
  81.                 }
  82.             }
  83.         }
  84.     }
Advertisement
Add Comment
Please, Sign In to add comment