I a开发者_如何学编程m 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".
I feel like I am back to basics and am missing something obvious. Can someone help me please? Thanks.
Codeigniter has functionality to get the input data.
Here are the CodeIgniter docs.
You can use it like this:
$this->input->post('some_data');
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...
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:
<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.
精彩评论