0

我有一个带有简单 mysql 搜索表单的 php 动态网站,这意味着带有获取页面变量的单个索引页面。

现在我的问题是当我进行搜索时,我的页面变量被唯一的搜索词替换。

请参阅下面的代码示例。

这是我的带有搜索表单的动态 php 起始页。

index.php?v=counselling

当我进行搜索时,我得到了这个..

index.php?name=value

在我的情况下,我的初始页面变量V被搜索词替换。

这是我的标签中的html..

 <form action="index.php?v=counselling" method="get">

我也尝试过$_SERVER['PHP_SELF'],但到目前为止没有运气。

我在这里做错了什么?

4

2 回答 2

2
<form action="index.php" method="get">
    <input type="hidden" name="v" value="counselling" />

将其作为隐藏输入值与您的搜索输入一起发送。

于 2012-04-24T06:55:37.953 回答
0

当您有查询字符串并一起发布数据时。你可以使用这个代码。HTML 代码:

<form action="index.php?v=counselling" method="post">
  <input type="text" name="post1" value="value" />
</form>

PHP代码:

echo "use $_GET and $_POST together. ";
echo $_POST['post1']. ' ' .$_GET['v'];
于 2012-04-25T12:46:30.730 回答