POST数据不在控制器codeigniter中

时间:2012-06-06 15:05:17

标签: php codeigniter

我发布了一个包含一些数据的表单但是我得到了空的POST数组。表格是

<form name="opening-statistics" action ="<?php echo base_url()?>statistic/openings">
   <select name="titles" multiple="multiple">
       <?php foreach($titles as $title) { ?> 
          <option value="<?php echo $title['idtitles']?>"><?php echo $title['title']?></option>
       <?php } ?>
    </select>
<input type="submit" name="submit" value="Submit">

在我的控制器中我有

 public function openings(){
    $data['boxes'] = $this->Statistic_model->getBoxes();
    $data['titles'] = $this->Statistic_model->getTitles();
    if($this->input->post()){
        echo 'I am here';
        $form = $this->input->post();
        var_dump($form);
        exit();
    }
    else{
        echo 'I am here';
        $this->load->view('statistic/openings-statistics', $data);
    }
} 

在我的路线中我有

$route['statistic/openings-statistics'] = 'statistic/openings';

总是来到else语句

任何人都能告诉我原因吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

尝试像这样捕捉POST:

 public function openings(){
    $data['boxes'] = $this->Statistic_model->getBoxes();
    $data['titles'] = $this->Statistic_model->getTitles();
    if($_POST){
        echo 'I am here';
        $form = $this->input->post();
        var_dump($form);
        exit();
    }
    else{
        echo 'I am here';
        $this->load->view('statistic/openings-statistics', $data);
    }
}

是的CI确实有:

$this->input->post(NULL, TRUE); // returns all POST items with XSS filter 
$this->input->post(); // returns all POST items without XSS filter