I am having the strangest problem and I don't know how to solve it. My form has as its first line:
我遇到了最奇怪的问题,我不知道如何解决它。我的表格有第一行:
<form action="index.php" method="POST">
but when I echo the $_SERVER['REQUEST_METHOD']
it echoes "GET". I am using CodeIgniter so I don't know if the problem is related to that. I thought it might be the form helper in CI but I wrote my form all in straight HTML and I still have the problem. The funny thing is if I copy the form into a local MAMP installation and run it, I get "POST".
但当我回显$ _SERVER ['REQUEST_METHOD']时,它回应了“GET”。我正在使用CodeIgniter,所以我不知道问题是否与此有关。我认为它可能是CI中的表单助手,但我用直接的HTML编写了我的表单,我仍然有问题。有趣的是,如果我将表单复制到本地MAMP安装并运行它,我会得到“POST”。
I feel like I am back to basics and am missing something obvious. Can someone help me please? Thanks.
我觉得自己回归基础,错过了一些明显的东西。有人能帮助我吗?谢谢。
3 个解决方案
#1
0
Sounds like CodeIgniter is running your post through some sort of cleanup process and as a results it is missing the actual method. With most php MVC frameworks, your are not supposed to access your form elements through $_POST and $_GET. They have their own wrappers to access these elements for security and cleanups...
听起来像CodeIgniter通过某种清理过程运行你的帖子,结果它缺少实际的方法。对于大多数php MVC框架,你不应该通过$ _POST和$ _GET访问你的表单元素。他们有自己的包装来访问这些元素以进行安全和清理......
#2
1
Codeigniter has functionality to get the input data.
Codeigniter具有获取输入数据的功能。
Here are the CodeIgniter docs.
以下是CodeIgniter文档。
You can use it like this:
你可以像这样使用它:
$this->input->post('some_data');
#3
0
Looks like the GET you see is simply code igniter url transformation. when you have something like localhost/main/page without htaccess and url cleanup is localhost/index.php?c=main&m=page, which is basically the GET request. By default CodeIgniter's politics on this subject is that you should always ignore using GET and only use POST; which is incredibly simple as stated in the other answers. In your form view:
看起来像你看到的GET只是代码点火器url转换。当你有像localhost / main / page这样没有htaccess的东西时,url cleanup是localhost / index.php?c = main&m = page,这基本上就是GET请求。默认情况下CodeIgniter关于这个主题的政治是你应该总是忽略使用GET并且只使用POST;如其他答案中所述,这非常简单。在您的表单视图中:
<input type="text" name="one" /> in your form
and catch it in your controller with
用你的控制器捕捉它
$value = $this->input->post('one');
Don't bother doing anything manually unless it is really necessary for your task.
除非你的任务真的有必要,否则不要手动做任何事情。
#1
0
Sounds like CodeIgniter is running your post through some sort of cleanup process and as a results it is missing the actual method. With most php MVC frameworks, your are not supposed to access your form elements through $_POST and $_GET. They have their own wrappers to access these elements for security and cleanups...
听起来像CodeIgniter通过某种清理过程运行你的帖子,结果它缺少实际的方法。对于大多数php MVC框架,你不应该通过$ _POST和$ _GET访问你的表单元素。他们有自己的包装来访问这些元素以进行安全和清理......
#2
1
Codeigniter has functionality to get the input data.
Codeigniter具有获取输入数据的功能。
Here are the CodeIgniter docs.
以下是CodeIgniter文档。
You can use it like this:
你可以像这样使用它:
$this->input->post('some_data');
#3
0
Looks like the GET you see is simply code igniter url transformation. when you have something like localhost/main/page without htaccess and url cleanup is localhost/index.php?c=main&m=page, which is basically the GET request. By default CodeIgniter's politics on this subject is that you should always ignore using GET and only use POST; which is incredibly simple as stated in the other answers. In your form view:
看起来像你看到的GET只是代码点火器url转换。当你有像localhost / main / page这样没有htaccess的东西时,url cleanup是localhost / index.php?c = main&m = page,这基本上就是GET请求。默认情况下CodeIgniter关于这个主题的政治是你应该总是忽略使用GET并且只使用POST;如其他答案中所述,这非常简单。在您的表单视图中:
<input type="text" name="one" /> in your form
and catch it in your controller with
用你的控制器捕捉它
$value = $this->input->post('one');
Don't bother doing anything manually unless it is really necessary for your task.
除非你的任务真的有必要,否则不要手动做任何事情。