Tidak bisa edit data pada CodeIgniter

saya saja · Oct 13, 2019

Jadi ketika sudah mengedit data dan di simpan, data tidak berubah pada database. Tampilan data masih sama seperti sebelum diedit.

CONTROLLER : public function edit($id) {

    $this->load->model('model_p');
    $data['project'] = $this->model_p->get($id);
    $this->load->view('edit_project', $data);
}
public function update()
{
    $this->load->model('model_p');
    $id = $this->input->post('id_project');
    $nama = $this->input->post('nama_project');
    $data = [
        'nama_project' => $nama,
    ];

    $save = $this->model_p->update($data, $id);

    if ($save) {
        $this->session->set_flashdata('msg_success', 'Data telah diubah!');
    } else {
        $this->session->set_flashdata('msg_error', 'Data gagal disimpan, silakan isi ulang!');
    }
    redirect('crud/project');
}

MODEL : public function Update($data, $id) { return $this->db->where('id_project', $id)->update('project', $data); }

public function get($id)
{
    return $this->db->where('id_project', $id)->get('project')->row();
}

    ******FORM EDIT DATA **
    <div class="container">
    <div class="col-md-9">
        <h3>Update</h3>
        <hr>
        <form action="<?php echo site_url('crud/project/update') ?>" method="post">
            <input type="hidden" name="id" value=" <?php echo $project->id_project ?> ">
            <div class="form-group">
                <label>Nama</label>
                <input type="text" name="nama" class="form-control" value="<?php echo $project->nama_project ?> ">
            </div>

            <input type="submit" class="btn btn-success" value="Simpan">
        </form>
    </div>
</div>
Silahkan login untuk menjawab!