[英]Keep $_GET['p'] when form method get is submitted
当我使用get方法提交表单时,get from表单将删除先前的?p=page1&title=food
。 我的网址看起来像localhost/test/index.php?p=page1&title=0
<form action="" method="get">
<input type="text" name="q" placeholder="Search" />
<input type="submit" />
</form>
我提交表单后,它将localhost/test/index.php?p=page1&title=0
替换为localhost/test/index.php?q=example
我希望将q
添加到带有&
的现有网址中
尝试使用隐藏字段再次发送值
<form action="" method="get">
<input type="hidden" name="p" value="<?php if(isset($_GET['p'])) echo $_GET['p'];?>" />
<input type="hidden" name="title" value="<?php if(isset($_GET['title'])) echo $_GET['title'];?>" />
<input type="text" name="q" placeholder="Search" />
<input type="submit" />
</form>
你也可以
<form action="?p=<?php echo $_GET[p];?>" method="get">
<input type="hidden" name="title" value="<?php echo $_GET['title'];?>" />
<input type="text" name="q" placeholder="Search" />
<input type="submit" />
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.