• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form Data reset before submit

#1
Hi, I have a form with  53 questions. Also I have set validation too. When I submit this form, if validation run, All my answered data has been reset. Any one have a solution for this?  My controller like below. 


PHP Code:
     public function sinhala()
 
       {
 
           if ($this->session->userdata('NAME')) {

 
               $this->load->helper(array('form''url'));
 
               $this->load->library('form_validation');

 
               $this->form_validation->set_rules('q1''Q1''required');
 
               $this->form_validation->set_rules('q2''Q2''required');
 
               $this->form_validation->set_rules('q3''Q3''required');
 
               $this->form_validation->set_rules('q4''Q4''required');
 
               $this->form_validation->set_rules('q5''Q5''required');
 
               $this->form_validation->set_rules('q6''Q6''required');
 
               $this->form_validation->set_rules('q7''Q7''required');
 
               $this->form_validation->set_rules('q8''Q8''required');
 
               $this->form_validation->set_rules('q9-1''Q9-1''required');
 
               $this->form_validation->set_rules('q9-2''Q9-2''required');
 
               $this->form_validation->set_rules('q9-3''Q9-3''required');
 
               $this->form_validation->set_rules('q9-4''Q9-4''required');
 
               $this->form_validation->set_rules('q9-5''Q9-5''required');
 
               $this->form_validation->set_rules('q9-6''Q9-6''required');
 
               $this->form_validation->set_rules('q9-7''Q9-7''required');
 
               $this->form_validation->set_rules('q9-8''Q9-8''required');
 
               $this->form_validation->set_rules('q9-9''Q9-9''required');
 
               $this->form_validation->set_rules('q8''Q8''required');
 
               $this->form_validation->set_rules('q10''Q10''required');
 
               $this->form_validation->set_rules('q11''Q11''required');
 
               $this->form_validation->set_rules('q12''Q12''required');
 
               $this->form_validation->set_rules('q33''Q13''required');
 
               $this->form_validation->set_rules('q14''Q14''required');
 
               $this->form_validation->set_rules('q15''Q15''required');
 
               $this->form_validation->set_rules('q16''Q16''required');
 
               $this->form_validation->set_rules('q17''Q17''required');
 
               $this->form_validation->set_rules('q19-a''Q19-A''required');
 
               $this->form_validation->set_rules('q19-b''Q19-B''required');
 
               $this->form_validation->set_rules('q18''Q18''required');
 
               $this->form_validation->set_rules('q20''Q20''required');
 
               $this->form_validation->set_rules('q21''Q21''required');
 
               $this->form_validation->set_rules('q22''Q22''required');
 
               $this->form_validation->set_rules('q23''Q23''required');
 
               $this->form_validation->set_rules('q24''Q24''required');
 
               $this->form_validation->set_rules('q25''Q25''required');
 
               $this->form_validation->set_rules('q26''Q26''required');
 
               $this->form_validation->set_rules('q27''Q27''required');
 
               $this->form_validation->set_rules('q28''Q28''required');
 
               $this->form_validation->set_rules('q29''Q29''required');
 
               $this->form_validation->set_rules('q30''Q30''required');
 
               $this->form_validation->set_rules('q31-a''Q31-A''required');
 
               $this->form_validation->set_rules('q31-b''Q31-B''required');
 
               $this->form_validation->set_rules('q31-c''Q31-C''required');
 
               $this->form_validation->set_rules('q32''Q32''required');
 
               $this->form_validation->set_rules('q33''Q33''required');
 
               $this->form_validation->set_rules('q34''Q34''required');
 
               $this->form_validation->set_rules('q35''Q35''required');
 
               $this->form_validation->set_rules('q36-1-1''Q36-1-1''required');
 
               $this->form_validation->set_rules('q36-1-2''Q36-1-2''required');
 
               $this->form_validation->set_rules('q36-2-1''Q36-2-1''required');
 
               $this->form_validation->set_rules('q36-2-2''Q36-2-2''required');
 
               $this->form_validation->set_rules('q36-3-1''Q36-3-1''required');
 
               $this->form_validation->set_rules('q36-3-2''Q36-3-2''required');
 
               $this->form_validation->set_rules('q36-4-1''Q36-4-1''required');
 
               $this->form_validation->set_rules('q36-4-2''Q36-4-2''required');
 
               $this->form_validation->set_rules('q36-5-1''Q36-5-1''required');
 
               $this->form_validation->set_rules('q36-5-2''Q36-5-2''required');
 
               $this->form_validation->set_rules('q37''Q37''required');
 
               $this->form_validation->set_rules('q38''Q38''required');
 
               $this->form_validation->set_rules('q39''Q39''required');
 
               $this->form_validation->set_rules('q40''Q40''required');
 
               $this->form_validation->set_rules('q41''Q41''required');
 
               $this->form_validation->set_rules('q42''Q42''required');
 
               $this->form_validation->set_rules('q43''Q43''required');
 
               $this->form_validation->set_rules('q44''Q44''required');
 
               $this->form_validation->set_rules('q45''Q45''required');
 
               $this->form_validation->set_rules('q46''Q46''required');
 
               $this->form_validation->set_rules('q47''Q47''required');
 
               $this->form_validation->set_rules('q48''Q48''required');
 
               $this->form_validation->set_rules('q49''Q49''required');
 
               $this->form_validation->set_rules('q50''Q50''required');
 
               $this->form_validation->set_rules('q51''Q51''required');
 
               $this->form_validation->set_rules('q52''Q52''required');


 
               if($this->form_validation->run() == TRUE)
 
               {

 
                   $this->Dashboard_model->insertAnswers();
                    
$this->form_validation->_field_data = array();
 
                   redirect('dashboard/sinhala');
 
               }


 
               $this->load->view('public/quections');
 
           } else{
 
               redirect('dashboard/index');
 
           }

 
         
        

 
This my model
PHP Code:
  public function insertAnswers()
 
   {
 
       $now date_default_timezone_set('Asia/Colombo'); // Set Time-Zone
 
       $now date('Y-m-d H:i:A'); //Format Date and time

 
       $data['q1'] = $this->input->post("q1");
 
       $data['q2'] = $this->input->post("q2");
 
       $data['q3'] = $this->input->post("q3");
 
       $data['q4'] = $this->input->post("q4");
 
       $data['q4-a'] = $this->input->post("q4-a");
 
       $data['q5'] = $this->input->post("q5");
 
       $data['q5-a'] = $this->input->post("q5-a");
 
       $data['q6'] = $this->input->post("q6");
 
       $data['q7'] = $this->input->post("q7");
 
       $data['q8'] = $this->input->post("q8");
 
       $data['q9-1'] = $this->input->post("q9-1");
 
       $data['q9-2'] = $this->input->post("q9-2");
 
       $data['q9-3'] = $this->input->post("q9-3");
 
       $data['q9-4'] = $this->input->post("q9-4");
 
       $data['q9-5'] = $this->input->post("q9-5");
 
       $data['q9-6'] = $this->input->post("q9-6");
 
       $data['q9-7'] = $this->input->post("q9-7");
 
       $data['q9-8'] = $this->input->post("q9-8");
 
       $data['q9-9'] = $this->input->post("q9-9");
 
       $data['q10'] = $this->input->post("q10");
 
       $data['q11'] = $this->input->post("q11");
 
       $data['q12'] = $this->input->post("q12");
 
       $data['q13'] = $this->input->post("q13");
 
       $data['q14'] = $this->input->post("q14");
 
       $data['q15'] = $this->input->post("q15");
 
       $data['q16'] = $this->input->post("q16");
 
       $data['q17'] = $this->input->post("q17");
 
       $data['q18'] = $this->input->post("q18");
 
       $data['q19-a'] = $this->input->post("q19-a");
 
       $data['q19-b'] = $this->input->post("q19-b");
 
       $data['q20'] = $this->input->post("q20");
 
       $data['q21'] = $this->input->post("q21");
 
       $data['q22'] = $this->input->post("q22");
 
       $data['q23'] = $this->input->post("q23");
 
       $data['q24'] = $this->input->post("q24");
 
       $data['q25'] = $this->input->post("q25");
 
       $data['q26'] = $this->input->post("q26");
 
       $data['q27'] = $this->input->post("q27");
 
       $data['q28'] = $this->input->post("q28");
 
       $data['q29'] = $this->input->post("q29");
 
       $data['q30'] = $this->input->post("q30");
 
       $data['q31-a'] = $this->input->post("q31-a");
 
       $data['q31-b'] = $this->input->post("q31-b");
 
       $data['q31-c'] = $this->input->post("q31-c");
 
       $data['q32'] = $this->input->post("q32");
 
       $data['q33'] = $this->input->post("q33");
 
       $data['q34'] = $this->input->post("q34");
 
       $data['q35'] = $this->input->post("q35");
 
       $data['q36-1-1'] = $this->input->post("q36-1-1");
 
       $data['q36-1-2'] = $this->input->post("q36-1-2");
 
       $data['q36-2-1'] = $this->input->post("q36-2-1");
 
       $data['q36-2-2'] = $this->input->post("q36-2-2");
 
       $data['q36-3-1'] = $this->input->post("q36-3-1");
 
       $data['q36-3-2'] = $this->input->post("q36-3-2");
 
       $data['q36-4-1'] = $this->input->post("q36-4-1");
 
       $data['q36-4-2'] = $this->input->post("q36-4-2");
 
       $data['q36-5-1'] = $this->input->post("q36-5-1");
 
       $data['q36-5-2'] = $this->input->post("q36-5-2");
 
       $data['q37'] = $this->input->post("q37");
 
       $data['q38'] = $this->input->post("q38");
 
       $data['q39'] = $this->input->post("q39");
 
       $data['q40'] = $this->input->post("q40");
 
       $data['q41'] = $this->input->post("q41");
 
       $data['q42'] = $this->input->post("q42");
 
       $data['q43'] = $this->input->post("q43");
 
       $data['q44'] = $this->input->post("q44");
 
       $data['q45'] = $this->input->post("q45");
 
       $data['q46'] = $this->input->post("q35");
 
       $data['q47'] = $this->input->post("q47");
 
       $data['q48'] = $this->input->post("q48");
 
       $data['q49'] = $this->input->post("q49");
 
       $data['q50'] = $this->input->post("q50");
 
       $data['q51'] = $this->input->post("q51");
 
       $data['q52'] = $this->input->post("q52");
 
       $data['q53'] = $this->input->post("q53");
 
       $data['created_at'] = $now;
 
       $data['created_by'] = $this->session->userdata('TOKEN');


 
       $this->db->insert('questions'$data);
 
   
Reply


Messages In This Thread
Form Data reset before submit - by sanjaya - 09-05-2018, 04:19 AM
RE: Form Data reset before submit - by sanjaya - 09-05-2018, 04:24 AM
RE: Form Data reset before submit - by qury - 09-05-2018, 04:39 AM
RE: Form Data reset before submit - by Nome - 09-05-2018, 05:00 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.