表单发送 GET 而不是 POST [英] Form sends GET instead of POST
问题描述
我已经搜索了所有标题相似的问题,但还没有解决方案.
I have searched the all questions with similar title, no solution for me yet.
我有一个在 apache2 上运行的网站.我需要通过表单提交敏感信息,我需要使用 POST 方法.它发送 GET 请求而不是 POST.
I have a website running on apache2. I need to submit sensitive information through a form and I need to use POST method. Instead of POST, it sends GET request.
HTML:
<form action="/add_user.php" method='POST'>
Enter Username: <input type="email" name="email" required="required" /> <br/>
Enter password: <input type="password" name="password" required="required" /> <br/>
<input type="submit" value="submit"/>
</form>
PHP:
<?php
$email=$_POST['email'];
$password=$_POST['password'];
//do stuff
?>
我在火狐浏览器中打开了网络监视器,确认方法为GET.我什至试图用 PUT 而不是 POST,它仍然发送 GET.此外,如果我将 $email
和 $password
更改为 $_GET
而不是 $_POST
,则会获取这些值.
I have opened Network monitor in Firefox, and the method is confirmed as GET. I have tried to even make it PUT instead of POST, still it sends GET. Also, $email
and $password
get the values if I change them to $_GET
instead of $_POST
.
任何帮助将不胜感激.
推荐答案
解决此问题的一种方法是通过显式formmethod="post"
来强化您的意图,如下所示:
One way to solve this is to reinforce your intentions by expliciting formmethod="post"
, like this:
<button type="submit" formmethod="post" formaction="add_user.php">Submit</button>
这篇关于表单发送 GET 而不是 POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!