1

我正在发布一个包含一些数据的表单,但我得到的是空的 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 语句中

谁能告诉我原因?

提前致谢

4

1 回答 1

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
于 2012-06-06T15:15:41.927 回答