提交表单时出现错误,“未定义的变量”“功能:_error_handler”

时间:2019-08-15 09:43:01

标签: php codeigniter

我正在尝试识别代码中的错误,我怀疑这是来自Controller的错误。

  

消息:未定义的变量:val

public function profile_updated()
{
    $user_id = $this->session->userdata('user_id');

    $profile_data = $this->settings_model->array_from_post(array('fullname', 'phone', 'language', 'locale'));


    //die(var_dump($_FILES['avatar']['name']));
    if (!empty($_FILES['avatar']['name'])) {

        $this->load->model('settings_model');
        $val = $this->settings_model->uploadImage("avatar");

        $strpos = strpos($val, "allowed");

        if($strpos==FALSE){

            $this->settings_model->_table_name = 'tbl_account_details';
            $this->settings_model->_primary_key = 'user_id';
            $this->settings_model->save($profile_data, $user_id);

            $client_id = $this->input->post('client_id', TRUE);
            if (!empty($client_id)) {
                $client_data = $this->settings_model->array_from_post(array('name', 'email', 'address'));
                $this->settings_model->_table_name = 'tbl_client';
                $this->settings_model->_primary_key = 'client_id';
                $this->settings_model->save($client_data, $client_id);
            }

            $type = "success";
            $message = lang('profile_updated');
            set_message($type, $message);
            redirect('client/dashboard'); //redirect page
        }else{
            $type= "error";
            $message = "Invalid file type";
            set_message($type, $message);
            redirect('client/dashboard');
        }

    }
    $profile_data['avatar'] = $val;
}

它旨在重定向到“客户端/仪表板”,但在“ profile_updated”处为空白

0 个答案:

没有答案