Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何自动向value$address添加内容?_Php_Forms - Fatal编程技术网

Php 如何自动向value$address添加内容?

Php 如何自动向value$address添加内容?,php,forms,Php,Forms,我有这个: echo '<input type="text" id="address" name="address" value="'.$address.'" />'; echo'; 当您在搜索表单中输入您的地址(my+address)并点击“search”按钮时,我想在链接中自动搜索添加cityname和country,链接看起来像…/index.php?address=my+address+citiname+county 提前谢谢 所以只需在post字段中使用method=“

我有这个:

echo '<input type="text" id="address" name="address" value="'.$address.'" />';
echo';
当您在搜索表单中输入您的地址(my+address)并点击“search”按钮时,我想在链接中自动搜索添加cityname和country,链接看起来像…/index.php?address=my+address+citiname+county


提前谢谢

所以只需在post字段中使用
method=“get”
,它就会将字段转储到URL

<form action="" method="get">
    <input  type="text" name="myAddress">
    <input type="text" name="city">
    <input type="text" name="county">
    <input type="submit" value="Go Search">
</form>


如果不想在字段中添加,则需要解析
myAddress
字段,并使用
元重定向来填充从其地址解析的数据。

这将更简单:

  • 在index.php中添加cityname和country(如果在会话中已知)
或:

  • 在表单中添加一个包含cityname和address的字段(可能是隐藏的),即使您将从表单中收到两个不同的值并需要合并它们


要准确地执行所需操作,您需要在提交查询之前修改查询;这是最容易做到的,例如使用jQuery。

Tnx!它起作用了!回声';现在链接看起来像…index.php?address=my+address&cityname+country,但是脚本不做这项工作,要脚本做这项工作,链接需要如下:…index.php?address=my+address+cityname+country,这是因为我有2个输入,并且需要在一个。。。要添加的内容接近value=“.$address.”或?Tnx!它和第二个一起工作!回声';现在链接看起来像…index.php?address=my+address&cityname+country,但是脚本不做这项工作,要脚本做这项工作,链接需要如下:…index.php?address=my+address+cityname+country,这是因为我有2个输入,并且需要在一个。。。要添加的内容接近value=“.$address.”或?你的第一个选择对我来说很难,但是tnx!