[eluser]doubleplusgood[/eluser]
Hi there.
I have a page in a user account for a user to edit their profile. The form itself has a hidden field with their id as follows;
Code:
<input type="hidden" id="profile_id" name="profile_id" value="<?php echo $profile->id; ?>" />
This is pulling through the correct id and the form fields are pulling through the correct details.
I also have a function as follows;
Code:
public function edit_profile($profile_id=-1){
if($profile_id===-1){
$profile_id=$this->input->post('profile_id');
}
$this->load->model('profile_model', 'profiles', TRUE);
$user = $this->auth->get_user();
$id = $this->user_id;
$view_data['title1'] = "Edit";
$view_data['title2'] = "Your Profile";
$view_data['title'] = "Edit Your Profile";
$view_data['profile'] = $this->profiles->get_edit_profile($profile_id);
if ( $this->auth->logged_in() )
{
$this->load->library('form_validation');
if ( $this->form_validation->run() == FALSE )
{
//die("validation false");
$view_data['view_file'] = 'account/edit_profile';
$this->load->view('layout', $view_data);
}
else{
$upl_images=array();
$this->load->library('upload');
$this->load->library('my_imglib');
for($i=1;$i<=6;$i++){
$data['upload_data']=array();
$upl_fname = '';
//die(print_r($_FILES));
$file = $_FILES['image'.$i];
$vimg='image'.$i;
$upl_images['image'.$i]=$view_data['vehicle']->$vimg;
if(isset($file['name'])){
if((trim($file['name'])!='')&&($file['name']!=NULL)){
$config['upload_path'] = './images/profiles/';
$config['allowed_types'] = 'gif|jpg|png';
$this->upload->initialize($config);
if(!$this->upload->do_upload('image'.$i)){
$this->session->set_flashdata('message', $this->upload->display_errors());
$this->load->view('account/edit_profile', $view_data);
exit();
}
else {
$data['upload_data'] = $this->upload->data();//print_r($data);
$upl_fname = $data['upload_data']['file_name'];
$std_path=$data['upload_data']['file_path']."std_".$upl_fname;
$mdm_path=$data['upload_data']['file_path']."mdm_".$upl_fname;
$tn_path=$data['upload_data']['file_path']."tn_".$upl_fname;
$upl_images['image'.$i]=$upl_fname;
$this->my_imglib->resize_image($data['upload_data']['full_path'],640,480,$std_path);
$this->my_imglib->resize_image($data['upload_data']['full_path'],250,188,$mdm_path); $this->my_imglib->resize_image($data['upload_data']['full_path'],93,70,$tn_path);
}
}
}
}
$profile=array(
'id'=>$this->user_id,
'first_name'=>$this->input->post('first_name'),
'last_name'=>$this->input->post('last_name'),
'business_name'=>$this->input->post('business_name'),
'business_postcode'=>$this->input->post('business_postcode'),
'business_email'=>$this->input->post('business_email'),
'business_phone'=>$this->input->post('business_phone'),
'business_website'=>$this->input->post('business_website'),
'business_photo'=>$upl_images['image1']
);
$this->profiles->update($profile_id,$profile);
$this->session->set_flashdata('message', 'Profile updated successfully');
redirect("account/vehicle_list");
}
}
else
{
redirect("account/index");
}
}
However, the form is not actually updating the content. I wondered if someone might be able to spot any obvious errors?
Thank you.