我在header.php
(每页的标题)中有一个搜索表单。提交表单后,我想将用户重定向到页面:site.com/search-$VALUE-100
。
我试过:
$value = $_POST['value'];
if(isset($_POST['search']))
{
if(preg_match('/^[a-zA-Z0-9]$/', $value))
{
header("Location: search-".$value."-100");
}
}
和 HTML:
<form method="get">
<input type="text" name="value" value="search" onfocus="if (this.value==this.defaultValue) this.value = ''" onblur="if (this.value=='') this.value = this.defaultValue" />
<input type="submit" name="search" class="image" value="" />
</form>
现在代码发送到:
page.php?value=a&search=
index.php?value=a&search=
user.php?value=a&search=
somepage.php?value=a&search=