CodeIgniter POST调用输出状态:303参见其他

问题描述 投票:0回答:1

我一直试图在Codeigniter中进行过去3天的POST调用,但无法获得POST数据。

我最初以表格格式使用它,但在探索时,我发现从CodeIgniter中的表中获取输入字段会造成许多错误。所以今天我用普通的输入元素尝试了它。我仍然无法检索POST数据。

页面URL形成:http://localhost/myproject/set-schedule

表格:

<?= form_open('set-schedule') ?>
              <div class="form-group">
                  <label>Select Date: </label>
                  <?php
                        $formData = "";
                        if(isset($_GET['date'])) {
                          $formData = $this->schedule_model->get_data($_GET['date']);
                          echo "<input type=\"text\" class=\"date-picker\" id=\"add_date\" value=" . $_GET['date'] ."></input>";
                        } else {
                          echo "<input type=\"text\" class=\"date-picker\" id=\"add_date\"></input>";
                        }
                  ?>
              </div>

                <div class="div-table">
                   <div class="div-table-row">
                      <div class="div-table-col heading" align="center">DATE</div>
                      <div  class="div-table-col heading">Head1</div>
                      <div  class="div-table-col heading">Head2</div>
                      <div  class="div-table-col heading">Head3</div>
                      <div  class="div-table-col heading">Head4</div>
                   </div>

                  <?php for ($row = 1; $row <= 7; $row ++) { ?>
                        <div class="div-table-row" id="form_data_custom">
                          <div class="div-table-col" align="center">
                            <?php echo "<input type='text' class='form-group' name='date_" . $row . "' placeholder='Enter DATE' readonly></input>"; ?>
                          </div>
                          <div class="div-table-col" align="center">
                            <?php echo "<input type='text' class='form-group' name='a_" . $row . "' placeholder='Enter Entry A'></input>"; ?>
                          </div>
                          <div class="div-table-col" align="center">
                            <?php echo "<input type='text' class='form-group' name='b_" . $row . "' placeholder='Enter Entry B'></input>"; ?>
                          </div>
                          <div class="div-table-col" align="center">
                            <?php echo "<input type='text'  class='form-group' name='c_" . $row . "' placeholder='Enter Entry C'></input>"; ?>
                          </div>
                          <div class="div-table-col" align="center">
                            <?php echo "<input type='text' class='form-group' name='d_" . $row . "' placeholder='Enter Entry D'></input>"; ?>
                          </div>
                        </div>
                  <?php } ?>

              </div>
              <div class="form-group text-right">
                <input type="submit" class="form-group btn btn-primary btn-sm" value="Submit"> Add/Update
                </input>
              </div>

            </form>

路线:

$route['set-schedule'] = 'schedule/set';

控制器(schedule.php):

    public function set()
    {
        var_dump('HERE');

        // create the data object
        $data = new stdClass();

        // load form helper and validation library
        $this->load->helper('form');
        $this->load->library('form_validation');


        $form_data = $this->input->post();
        echo json_encode($_POST);
        echo json_encode("----");
        echo json_encode($form_data);

        ........
}

将所有POST数据都设为NULL

请指导我可能出错的地方。谢谢

php forms codeigniter post codeigniter-3
1个回答
1
投票

你试过这个:

使用这行代码

     public function set()
     {
        var_dump($this->input->post());
        /*--OR---*/
        var_dump($_REQUEST);
         /*--OR---*/
        print_r($this->input->post());
        die;
     }
© www.soinside.com 2019 - 2024. All rights reserved.