php - 将 url 参数传递到搜索表单

标签 php forms parameters

确切的问题:尝试将参数从 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/

相关文章:

php - 要求作者为帖子设置特色图片

php - 多个 AND 的组合,NOT IN 条件在 php mysql 查询中不能正常工作

forms - 将公式添加到 Gravity Forms 表单

javascript - 使用 Angular 工厂中的参数进行自定义 header

php - 以与保存时相同的模式显示 mysql 结果

php 将十六进制数 273ef9 隐藏到路径 27/3e/f9

forms - 如何在奏鸣曲管理包中将 NULL 作为数据网格关系中的选项?

forms - History.pushstate 和 HTTP POST 表单转发

powershell - 如何从 Powershell 将参数传递到批处理文件

java - 可以传递 JFrame 作为参数,然后我得到我创建的字段吗?