Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为什么我要在POST表单中获取VAR?_Html_Post_Get - Fatal编程技术网

Html 为什么我要在POST表单中获取VAR?

Html 为什么我要在POST表单中获取VAR?,html,post,get,Html,Post,Get,我有以下代码: <? $page = $_GET['page']; $find = $_GET['find']; ?> <form method="post" action="#"> <input type="text" name="whatever" value="1"> <button class="btn btn-default" type="submit">Post this</button> </form&g

我有以下代码:

<? 
$page = $_GET['page'];
$find = $_GET['find'];
?>

<form method="post" action="#">
  <input type="text" name="whatever" value="1">
  <button class="btn btn-default" type="submit">Post this</button>
</form>

张贴此
我的初始URL是: htttp://www.someplace.com?page=1&find=lookfor

当发送post表单时,我将返回“page”和“find”变量以及“whatever”输入值。为什么?这是因为我的表单动作是“#”吗

顺便说一句,这就是我想要的,这节省了我发布隐藏输入值的工作。但是我想确定它是否有效。

使用
action=“#”
,您将表单提交到当前URL。您的GET VAR是此URL的一部分,这就是您再次获取它们的原因


有关的更多信息。

尝试将
操作=“#”
替换为
操作=“
。这能解决问题吗?@AnisR。对我来说不是问题,只是想知道为什么会发生这种情况。谢谢