[eluser]Ignis Avis[/eluser]
I am using codeigniter to build a user profile system.
when I am updating the profile it is not working.
My controller function:
Code:
public function update() {
$id = $this->uri->segment(3);
if ($this->input->server('REQUEST_METHOD') === 'POST')
{
if ($this->form_validation->run('valid_students'))
{
$data_to_store = array(
'father_name' => $this->input->post('father_name'),
'mother_name' => $this->input->post('mother_name'),
'local_gurdian' => $this->input->post('local_gurdian'),
'phone' => $this->input->post('phone'),
'address' => $this->input->post('address'),
'email' => $this->input->post('email')
);
if($this->student_model->update_student_contact_info($id, $data_to_store) == TRUE) {
echo "NOT BOOM!!!";
redirect('index.php/student/view_profile/'.$id);
} else {
echo "BOOM!!!";
}
}
}
$data['student'] = $this->student_model->get_student_by_id($id);
//load the view
$data['content'] = 'profile_edit';
$this->load->view('layout', $data);
}
My model function:
Code:
public function update_student_contact_info($id, $data) {
$this->db->where('student_gen_id', $id);
$this->db->update('student_info', $data);
$report = array();
$report['error'] = $this->db->_error_number();
$report['message'] = $this->db->_error_message();
if($report !== 0){
return true;
}else{
return false;
}
}
in the view file i am defining form action as follow:
Code:
echo form_open('index.php/student/update/'.$this->uri->segment(3).'', $attributes); ?>
When I hit edit button the form appers but when i edit and press save button nothing is changed.