确切的问题:尝试将参数从 url 传递到搜索框目标页面。
参数是这样的“subid”:
http://www.domain.com/?subid=3456
以及 php 中当前(非工作)搜索表单代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<form action="http://search.yahoo.com/search?subid=<?php print $_GET['subid'];?>&" target="_blank" id="search-box">
<input type="text" name="p" size="31" />
<input type="submit" value="Search" />
</form>
</body>
</html>
当我转到此处时,我可以使用 firebug 看到 subid 在表单操作中:
http://www.domain.com/?subid=3456
但是当我在表单中运行查询时,没有传递给雅虎。
那么问题出在哪里呢?
最佳答案
您还应该将 subid
作为参数发布,并将方法指定为 get
。
<form action="http://search.yahoo.com/search" target="_blank" method="get" id="search-box">
<input type="hidden" name="subid" value="<?php print $_GET['subid'];?>" />
<input type="text" name="p" size="31" />
<input type="submit" value="Search" />
</form>
关于php - 将 url 参数传递到搜索表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16592003/