1

I am posting a form with some data but I am getting empty POST array. The form is

<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">

In my controller I have

 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);
    }
} 

In my routes I have

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

It always come to the else statement

Anyone can tell me the reason ?

Thanks in advance

Zoha Ali Khan
  • 1,659
  • 11
  • 37
  • 56

1 Answers1

0

Try catching the POST like this:

 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);
    }
}

And Yes CI does have:

$this->input->post(NULL, TRUE); // returns all POST items with XSS filter 
$this->input->post(); // returns all POST items without XSS filter
greenLizard
  • 2,326
  • 5
  • 24
  • 30