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

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

问题描述

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



A print_r $ _POST)完全正确地提供所有变量?



根据codeigniter docs,输入类由系统自动初始化没有必要手动,让我想知道我还有什么意思。



有什么想法,我应该如何努力让这个工作? / p>

谢谢!

解决方案

(正确):

 < form method =postaction =/ controller / submit /> 

vs(不起作用):

 < form method =postaction =/ controller / submit> 

这里的第二个是不正确的,因为它重定向而不继承post变量。



说明:



当url最后没有斜杠时,一个文件。



现在,当Web服务器查找文件时,它看到,这真的是一个目录,并发送一个重定向到浏览器, 。



浏览器使用斜线对新网址进行新查询,但不会发布表单内容。这是表单内容丢失的地方。


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) gives all the variables fully and correctly?

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?

Thanks!

解决方案

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

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

vs (doesn't work):

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

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

Explanation:

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

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.

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.

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

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