【问题标题】:Why Post request not working on server with codeigniter 4?为什么 Post 请求在使用 codeigniter 4 的服务器上不起作用?
【发布时间】:2020-10-15 11:05:36
【问题描述】:

我开始使用 codeigniter 4。在 localhost 上一切正常,但在主机上安装后,只有“发布”请求不起作用。发布请求后我无法获得任何价值。

HTML:

<form  action="<?php echo base_url()."/slider/ekle" ?>" method="POST" enctype="multipart/form-data" >

        <div class="form-group">
          <label>Başlık</label>
          <input type="text" class="form-control"  placeholder="Slider başlığı" name="baslik" value=""/>
  
       </div>

      <div class="form-group mb-0">
         <div>
            <button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Ekle</button>
         </div>
      </div>
</form>

Ekle.php(控制器)

public function ekle()
{
    $baslik=$this->request->getPost("baslik");
    $aciklama=$this->request->getPost("aciklama");
    print_r($baslik);
    die();
}

我的意思是每个代码在“localhost”上运行良好,但“post”请求在我的远程主机上不起作用。

【问题讨论】:

  • 这是一个碎主机吗?也许您已阻止发布请求。它在什么 print_r 上看起来像什么?
  • "
  • @DhavalChheda 它位于路径的末尾。点将基本 url 函数的输出连接到路径字符串。

标签: php post request codeigniter-4


【解决方案1】:

使用$this-&gt;request-&gt;getVar() 代替$this->request->getPost()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-17
    • 1970-01-01
    相关资源
    最近更新 更多