当我使用 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
添加到现有的 url
最佳答案
尝试使用隐藏字段再次发送值
<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>
关于php - 提交表单方法get时保留$_GET ['p'],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24182948/