简体   繁体   English

浏览器将HTTP POST请求作为GET请求发送

[英]Browser sends HTTP POST requests as GET requests

I have a PHP Application which is written using CodeIgniter. 我有一个使用CodeIgniter编写的PHP应用程序。 I am facing a strange problem regarding HTTP requests. 我面临有关HTTP请求的奇怪问题。 I noticed that the chrome developer tool shows the results of the HTTP request methods as 404 Not found but I can receive the response from the application. 我注意到chrome开发人员工具将HTTP请求方法的结果显示为404 Not found但是我可以从应用程序接收响应。 Also another problem and my main problem is that the HTTP post requests are being sent as GET requests, however they are sent as GET methods. 还有一个问题,也是我的主要问题,HTTP发布请求是作为GET请求发送的,但是它们是作为GET方法发送的。 Here is the HTML form which sends the request: 这是发送请求的HTML表单:

<form name="form" id="form" action="login" class="form-horizontal" method="POST">
    //                          
</form>

And if I debug the request by printing the value of $_SERVER variable I can see that the request method is GET : 如果我通过打印$_SERVER变量的值调试请求,我可以看到请求方法是GET

'SERVER_PROTOCOL' => string 'HTTP/1.1' (length=8)
'REQUEST_METHOD' => string 'GET' (length=3)
'QUERY_STRING' => string '' (length=0)

And also there are these two more options that I don't know what they mean: 还有另外两个我不知道它们意味着什么的选项:

'REDIRECT_REQUEST_METHOD' => string 'POST' (length=4)
'REDIRECT_STATUS' => string '404' (length=3)

I am using Wamp on Windows 8.1 and CodeIgniter. 我在Windows 8.1和CodeIgniter上使用Wamp。

<form action="<?php echo base_url()?>index.php/login/function_name" method="post">
    <input  type="text" name="name"> 
    <input  type="email" name="email" > 
   <input  type="submit" name="submit" value="Submit" > //Important, this only submit the form 
</form

In login controller login控制器中

public function function_name()
    {
        $name= $_POST['name']
        $email= $_POST['email']

        echo 'Name is :'.$name. 'and E-mail is : '.$email;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM