Codeigniter $this->input->post() 为空,而 $_POST 工作正常 [英] Codeigniter $this->input->post() empty while $_POST is working correctly

查看:34
本文介绍了Codeigniter $this->input->post() 为空,而 $_POST 工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 codeigniter 安装中,我尝试使用内置的 $this->input->post('some_data') 函数,但是 $this->input->post() 是一个空数组.

On a codeigniter installation, I am trying to use the inbuilt $this->input->post('some_data') function, however $this->input->post() is an empty array.

A print_r($_POST) 完整正确地给出所有变量?

A print_r($_POST) gives all the variables fully and correctly?

根据 codeigniter 文档,输入类由系统自动初始化,因此无需手动执行",让我想知道我还想做什么.

According to the codeigniter docs, The input class "is initialized automatically by the system so there is no need to do it manually", leaving me wondering what else I'm meant to do.

对我应该如何尝试使其工作有任何想法吗?

Any thoughts on how I should try to get this working?

谢谢!

推荐答案

你可以检查一下,如果你的视图看起来像这样(正确):

You can check, if your view looks something like this (correct):

<form method="post" action="/controller/submit/">

vs(不起作用):

<form method="post" action="/controller/submit">

这里的第二个是不正确的,因为它重定向而不携带 post 变量.

Second one here is incorrect, because it redirects without carrying over post variables.

说明:

当url末尾没有斜线时,表示this指向一个文件.

When url doesn't have slash in the end, it means that this points to a file.

现在,当 Web 服务器查找该文件时,它会发现这实际上是一个目录,并向浏览器发送重定向,并以斜杠结尾.

Now, when web server looks up the file, it sees, that this is really a directory and sends a redirect to the browser with a slash in the end.

浏览器使用斜杠对新 URL 进行新查询,但不发布表单内容.这就是表单内容丢失的地方.

Browser makes new query to the new URL with slash, but doesn't post the form contents. That's where the form contents are lost.

这篇关于Codeigniter $this->input->post() 为空,而 $_POST 工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆