dtmu88600 2018-03-28 08:48
浏览 24
已采纳

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

I have been trying to make a POST call in Codeigniter for past 3 days but unable to get POST Data.

I initially had it in table format, but on exploring, I found that getting input fields from table in CodeIgniter has posed many errors. SO today I tried it with normal input elements. I am still unable to retrieve the POST data.

Page URL formed : http://localhost/myproject/set-schedule

Form :

<?= 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>

Routes :

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

Controller (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);

        ........
}

Getting all POST Data as NULL

Please guide on where I might be going wrong. Thanks

  • 写回答

1条回答 默认 最新

  • dousui6193 2018-03-28 09:23
    关注

    Have you tried this :

    use this line of code

         public function set()
         {
            var_dump($this->input->post());
            /*--OR---*/
            var_dump($_REQUEST);
             /*--OR---*/
            print_r($this->input->post());
            die;
         }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan