controller
public function respondent_info()
{
$data['states'] = $this->survey_model->get_states();
$state = $this->session->store['loginData']['state'];
$financial_year = $this->session->store['loginData']['financial_year'];
$getData = $this->survey_model->get_page($state, $financial_year);
if ($getData == '1') {
$data['res_info'] = $this->survey_model->get_resinfo_details($state);
$this->load->view('edit_respondent_info', $data);
}else {
$this->load->view('respondent_info', $data);
}
if(isset($_POST['submit_x'])) {
$respondentArray = array(
'state' => empty($_POST['state']) ? '' : $_POST['state'],
'name' => empty($_POST['name']) ? '' : $_POST['name'],
'title1' => empty($_POST['title1']) ? '' : $_POST['title1'],
'dline' => empty($_POST['dline']) ? '' : $_POST['dline'],
'email' => empty($_POST['email']) ? '' : $_POST['email'],
'organization' =>empty( $_POST['organization']) ? '' : $_POST['organization'],
'address' => empty($_POST['address']) ? '' : $_POST['address'],
'city' => empty($_POST['city']) ? '' : $_POST['city'],
'state1' =>empty( $_POST['state1']) ? '' : $_POST['state1'],
'zip' => empty($_POST['zip']) ? '' : $_POST['zip'],
'phone' => empty($_POST['phone']) ? '' : $_POST['phone'],
'fax' =>empty( $_POST['fax']) ? '' : $_POST['fax'],
);
$this->session->set_userdata('respondent_info',$respondentArray);
$this->survey_model->auto_save_respondent_info( $_POST);
redirect('survey/budget_overview');
}
}
model
function auto_save_respondent_info($post){
echo("auto");
$respondentArray = array(
'survey_id' => $this->session->store['survey_id'],
'state' => empty($_POST['state']) ? '' : $_POST['state'],
'name' => empty($_POST['name']) ? '' : $_POST['name'],
'title1' => empty($_POST['title1']) ? '' : $_POST['title1'],
'dline' => empty($_POST['dline']) ? '' : $_POST['dline'],
'email' => empty($_POST['email']) ? '' : $_POST['email'],
'organization' =>empty( $_POST['organization']) ? '' : $_POST['organization'],
'address' => empty($_POST['address']) ? '' : $_POST['address'],
'city' => empty($_POST['city']) ? '' : $_POST['city'],
'state1' =>empty( $_POST['state1']) ? '' : $_POST['state1'],
'zip' => empty($_POST['zip']) ? '' : $_POST['zip'],
'phone' => empty($_POST['phone']) ? '' : $_POST['phone'],
'fax' =>empty( $_POST['fax']) ? '' : $_POST['fax'],
);
$this->db->select('*');
$this->db->from('survey_respondent_info');
$this->db->where('state', $state);
$query = $this->db->get();
if ($query->num_rows() > 0)
{
echo("update");
// $this->db->where('state', $state);
// $this->db->update('survey_respondent_info', $resInfoArray);
}
else{
echo("insert");
// $this->db->insert('survey_respondent_info', $resInfoArray);
}
}
here it is not calling the model function, am not able to view the data given in echo. How to call it or how to send the data stored in session to model, i know that something missing in my code, can someone help me please. thanks.