在Codeigniter中提交后获取空白页?

时间:2017-12-02 08:05:23

标签: php mysql codeigniter-3

我正在研究CI,我创建了一个简单的CRUD,用于在表格中插入带有一些数据的PDF。有时我的代码有效,但现在它完全不起作用。我在提交表单后得到空白页面。并没有像print_r和var_dump等那样发生。我不知道我的代码中有什么不对。

我的侧边栏: 从我点击我的控制器来获取我的观点。

 <li><a href="<?php echo site_url('responsible/add_pay_slips');?>">Upload Pay slips</a></li> 

工作正常。点击此按钮,我可以转到我的add_pay_slips页面。

相同的控制器:

 public function add_pay_slips()
  { 
    $this->load->view('layouts/header');
    $this->load->view('layouts/sidebar');
    $data['salary']=$this->pay_slips->getPaySlips1();    
    $this->load->view('responsibilities/add_pay_slips',$data);
    $this->load->view('layouts/footer');
  }

在此之后,我得到了表单视图:

          <form  method="post"  enctype="multipart/form-data" class="form-horizontal" action="<?php echo base_url();?>responsible/upload">
        <div class="control-group">
          <label class="control-label">Select Month</label>
          <div class="controls">
            <select name="month">
              <option value="1">January</option>
              <option value="2">February</option>
              <option value="3">March</option>
              <option value="4">April</option>
              <option value="5">May</option>
              <option value="6">June</option>
              <option value="7">July</option>
              <option value="8">August</option>
              <option value="9">September</option>
              <option value="10">October</option>
              <option value="11">November</option>
              <option value="12">December</option>
            </select>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label">Select Year</label>
          <div class="controls">
            <select name="year">
              <option>2017</option>
              <option>2016</option>
              <option>2015</option>                 
              <option>2014</option>                 
              <option>2013</option>
              <option>2012</option>
              <option>2011</option>                 
            </select>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label">Select Employee</label>
          <div class="controls">               
            <select name="employee_name">
            <?php 
              foreach ($salary  as $row) {?>
              <option value='<?php echo $row->EMPLOYEE_ID;?>'><?php  echo $row->EMPLOYEE_NAME;}?></option>
              <!--<input type="hidden" name="employee_id" value="<?php //echo $row->EMPLOYEE_ID?>">-->

            </select>            
          </div>
        </div>
               <div class="control-group">
          <label class="control-label">Select Country</label>
          <div class="controls">               
            <select name="org_id">            
              <option  value="40">UK</option>        
              <option  value="65">INDIA</option>
              <option  value="47">POLAND</option> 
              <option  value="57">GERMANY</option>  
            </select>            
          </div>
        </div>          
        <div class="control-group">
          <label class="control-label">Upload Payslip</label>
          <div class="controls">
            <input type="file"  name="userfile"/>
          </div>
        </div>           
        <div class="form-actions">
          <button type="submit" class="btn btn-success">Save</button>
        </div>
      </form>

对于提交按钮上的这个视图,我创建了一个控制器来插入数据。

    function upload(){

    $filename = 'pdf';
    $config = array(
      'upload_path' => 'uploads',
      'allowed_types' => "pdf",
      'file_name' => $filename
    );
    $config['allowed_types'] = 'pdf';
    $this->load->library('upload', $config);
    $this->upload->initialize($config);
    if($this->upload->do_upload())
      {
      $file_data = $this->upload->data();      
      $data1['userfile'] = $file_data['file_name'];
      $data=
      array(
      'PAY_MONTH'=>$this->input->post('month'),
      'PAY_YEAR'=>$this->input->post('year'),
      'ORG_ID'=>$this->input->post('org_id'),
      'EMPLOYEE_ID'=>$this->input->post('employee_name'),
      'PDF'=>$data1['userfile'],
      );      
      $this->load->model('pay_slips_model');
       $result=$this->pay_slips->insert_payslips($data);
      if($result==true)
        {
          $this->session->set_flashdata('msg',"PDF  Added Successfully");     
          $this->load->view('layouts/header');
          $this->load->view('layouts/sidebar');
          $data['salary']=$this->pay_slips->getPaySlips1();    
          $this->load->view('responsibilities/add_pay_slips' ,$data,'refresh');
          $this->load->view('layouts/footer');


        }
      else
        {



          $this->seesion->set_flashdata('msg1',"PDF Added Failed");
          redirect('responsibilities/add_pay_slips');


        }     
      }

  }

为此,我有一个模型来插入数据。

public function insert_payslips($data)
        {
            $this->db->insert('all_salary_slip_details',$data);
            return ($this->db->affected_rows() != 1 ) ? false:true;
        }

我有一个页面负责。我的所有控制器都在同一页面上。影响我的代码的是什么。我被困在这里。 Onclick提交我刚拿到我的控制器的网址和空白页面。 payroll1/responsible/upload

0 个答案:

没有答案