Skip to content Skip to sidebar Skip to footer

Tutorial on Creating a Web Course Registration Using Codeigniter: Update & Delete [Bagian 13]

This article will discuss to add update function and delete on the participant data page. For loyal Inwepo readers who have just joined the process of creating this course registration website, readers canreview manufacturing process from scratch.

Read also:

MAKING FUNCTION UPDATE AND DELETE

1. Open files welcome.php contained in folder C:\xampp\htdocs\inwepo\application\controllers.

function hapus($id)  {        $this->m_kursus->delete($id);        redirect('user/welcome/daftar_peserta_kursus');  }  function ubah($id)   {        if($_POST==NULL) {            $data['title']="Edit Data Peserta";            $data['dt_peserta'] = $this->m_kursus->select($id);            $user = $this->session->userdata('username');            $this->data['pengguna'] = $this->m_login->data($user);            $this->load->view('user/header',$this->data);            $this->load->view('user/form_edit_peserta',$data);            $this->load->view('user/footer');        }else {            //$id=$this->input->post('id'); error            $npm=$this->input->post('npm');            $nama=$this->input->post('nm_peserta');            $kursus=$this->input->post('nm_kursus');            $periode=$this->input->post('periode');            $kelas=$this->input->post('kelas');            $jurusan=$this->input->post('jurusan');            $this->m_kursus->update($id,$npm,$nama,$kursus,$kelas,$jurusan,$periode);            redirect('user/welcome/daftar_peserta_kursus');        }  }

Purpose of manufacture function delete and change this to delete and edit existing participant data in user dashboards. So that when an error occurs during the data entry process, the user can perform the editing stage or even delete the personal data.

2. Open files M_course.php in the folder C:\xampp\htdocs\inwepo\application\models to add the following program snippet:

function delete($id)  {	 $this->db->delete('peserta', array('id'=>$id)); } function update($id,$npm,$nama,$nama_kursus,$kelas,$jurusan) {	$data = array(			'npm'=>$npm,			'nama'=>$nama,			'nm_kursus'=>$nama_kursus,			'kelas'=>$kelas,			'jurusan'=>$jurusan,			);	$this->db->where('id',$id)->update('peserta', $data); } function select($id)  {	 return $this->db->get_where('peserta', array('id'=>$id))->row(); }

Now, users can edit biodata as shown in the image below:

If you have finished editing the participant data and pressing the edit button at the end of the form, then the data that has been entered will change like what the user did earlier.

Well, we finally come to the end of page creation users. Therefore, the author will provide source code as well as live demo from the application that the author has made from scratch. However, you can look forward to the creation process for the admin page which will later serve to manage the course schedule as well as view the participants who have signed up for the desired course.

Finally, the author would like to thank you for the participation of Inwepo loyal readers who participated in the manufacturing process website course registration using this codeigniter. Look forward to the process of creating an admin page! Hello coding…

DOWNLOAD LINKS

Download Inwepo.SQL

Download Source Code