点击提交按钮后无法重定向

时间:2015-07-23 07:39:03

标签: php codeigniter

我正在尝试上传已编辑的csv文件,但在提交后它不会重定向 有效的消息。实际上如果在编辑的csv文件中有任何错误,它应该给出错误消息,否则成功消息。

我想上传特定主题的标记表,如果输入的标记不是数字或超过最大标记,则会显示有效消息并重定向回我的视图页。

   function import_academic_excel()
 {    
    $optional_index = 0;    
    if ($this->input->post('submit'))
    {     
        $config['upload_path'] = './application/temp_upload/';
        $config['allowed_types'] = 'csv'; 
        $this->load->library('upload', $config); 
        if (!$this->upload->do_upload('userfile'))
        {  
            $data = array('error' => $this->upload->display_errors()); 
            $this->session->set_flashdata('msg_excel','Choose a .csv file to upload.'); 
            redirect(base_url().'import_evaluation_sheet');  
        }
        else
        {    

          $count_numeric = 0;
            $count_maximum = 0; 

            foreach($result as $field)
            {    
                if($standard == 11 || $standard == 12)
                {  
                   if($evaluation_name == 'ta1' || $evaluation_name == 'ta2' || $evaluation_name == 'ta3')
                        {  

    if($subject_name == 'physics' || $subject_name == 'chemistry' || $subject_name == 'computer_science')   
                            {
                                $theory_name=$subject_name.'_theory';  
                                $practical_name=$subject_name.'_practical';  
                                if($field[$theory_name] == '' )
                                {
                                    $field[$theory_name]=  0; 
                                } 
                                if($field[$practical_name] == '' )
                                {
                                    $field[$practical_name]=  0; 
                                } 
                                if($field[$theory_name] != 'ab') 
                                {
                                    if(!is_numeric($field[$theory_name]))
                                    {   
                                        $count_numeric = $count_numeric + 1;    
                                    }
                                    if($field[$theory_name] > $theory_mark)
                                    {
                                        $count_maximum = $count_maximum + 1;  
                                    }  
                                }
          }
        }
     }
   } 
  }
       if($count_numeric > 0)
        {
            $this->session->set_flashdata('msg_excel','Please check the marks entered in the file, some marks are not numeric.'); 
            redirect(base_url().'import_evaluation_sheet');   
        }         
        if($count_maximum > 0)
        {     
            $this->session->set_flashdata('msg_excel','Please check the marks entered in the file, some marks exceeds the maximum marks.');  
            redirect(base_url().'import_evaluation_sheet');   
        }
                   $update_result= $this->data->update_chapter($result,$subject_name,$evaluation_name,$optional_index,$standard,$tool_id);                    
        $this->session->set_flashdata('msg_excel_success','Updated data successfully'); 
        redirect(base_url().'import_evaluation_sheet');  
    }
   }

循环正在运行,但它无法进入最后两个if循环。 如果我输入有效的csv文件,它将反映在数据中,但无法显示成功消息。

0 个答案:

没有答案