Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- model site_model.php :
- // insert data ke database dirubah //
- function tambah_con($data) {
- $this->db->insert('confirm', $data);
- }
- controller home.php :
- // function do_upload diganti ini //
- public function do_upload()
- {
- $config['upload_path'] = "./asset/images/"; //lokasi folder yang akan digunakan untuk menyimpan file
- $config['allowed_types'] = 'gif|jpg|png|JPEG'; //extension yang diperbolehkan untuk diupload
- $config['max_size'] = '1024';
- $config['file_name'] = url_title($this->input->post('file_upload'));
- $this->upload->initialize($config); //meng set config yang sudah di atur
- if( !$this->upload->do_upload('file_upload'))
- {
- echo $this->upload->display_errors();
- }
- else{
- $this->session->set_flashdata('message', '<strong>Congratulation,</strong> you have been registered in this programme, We will change your participant status to be confirmation
- and after that we will send your invitation letter at your <strong>Email.</strong>');
- $data = array(
- 'name'=>$this->upload->file_name
- );
- $this->site_model->insert($data,'images');
- //redirect('home/add_con');
- return $this->upload->file_name;
- }
- }
- // function simpan_con diganti ini //
- function simpan_con() {
- $this->form_validation->set_rules('select1', 'Full Name', 'trim|required');
- $this->form_validation->set_rules('account', 'Account Name', 'trim|required');
- $this->form_validation->set_rules('bank', 'Bank Name', 'trim|required');
- $this->form_validation->set_rules('tanggal', 'Date of make a Payment', 'trim|required');
- $this->form_validation->set_rules('file_upload', 'File Upload', 'trim|required');
- if ($this->form_validation->run() == FALSE) {
- if ($this->input->post('submit')) {
- $this->data['select1'] = $this->input->post('select1');
- $this->data['id_jen'] = $this->input->post('id_jen');
- $this->data['st'] = $this->input->post('st');
- $this->data['account'] = $this->input->post('account');
- $this->data['bank'] = $this->input->post('bank');
- $this->data['tanggal'] = $this->input->post('tanggal');
- $this->data['content'] = 'confirm_p';
- $this->load->view('template', $this->data);
- }
- } else {
- $this->session->set_flashdata('message', '<strong>Congratulation,</strong> you have been registered in this programme, We will change your participant status to be confirmation
- and after that we will send your invitation letter at your <strong>Email.</strong>');
- $st = $this->input->post('st');
- if ($this->input->post('submit')) {
- if (trim($st)=="tambah") {
- $this->load->model('site_model');
- $name = $this->input->post('select1');
- $account = $this->input->post('account');
- $bank = $this->input->post('bank');
- $tgl = $this->input->post('tanggal');
- $upload = $this->do_upload();
- $data = array('id_jen' => NULL,
- 'name' => $this->input->post('select1');,
- 'acco' => $this->input->post('account'),
- 'bank' => $this->input->post('bank'),
- 'tgl' => $this->input->post('tanggal'),
- 'file' => $upload
- );
- $this->site_model->tambah_con($data);
- redirect('home/add_con');
- }
- else if (trim($st)=="edit") {
- $this->session->set_flashdata('message', 'Selamat, Anda telah berhasil melakukan Registrasi');
- $id_jenis = $this->input->post('id_jenis');
- $this->load->model('site_model');
- $this->site_model->update($id_jenis);
- redirect('home/table');
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment