我正在创建PHP搜索表单,我想在URL上显示搜索变量名称,像这样的http://localhost/zblog/results/1/我想得到这样的URL
http://localhost/zblog/results/1/xxcxcxc
这是我的代码
<?php
$search = $_POST["search"];
?>
<form action="<?php echo $url; ?>results/1/<?php echo $search; ?>" method="post" name="search" id="searchthis" style="display:inline;">
<input id="search-box" name="search" size="40" type="text" placeholder="what are you looking for............"/>
<input id="search-btn" value="search" type="submit"/>
</form>
答案 0 :(得分:0)
您需要将表单方法更改为method =“ get”,并检查$ search获得正确的值。
<?php
$search = $_GET["search"];
?>
<form action="<?php echo $url; ?>results/1/<?php echo $search; ?>" method="get" name="search" id="searchthis" style="display:inline;">
<input id="search-box" name="search" size="40" type="text" placeholder="what are you looking for............"/>
<input id="search-btn" value="search" type="submit"/>
</form>