将URL参数添加到表单PHP HTML [英] adding URL parameters to a form PHP HTML

查看:256
本文介绍了将URL参数添加到表单PHP HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < form method ='get可以正确或正确地使用url get参数吗? 'action ='index.php?do = search'> 
< input name ='_ search'type ='text'value ='你在找什么?'>
< button type ='submit'>搜寻< /按钮>
< / form>

当我提交表单时,网址更改为:

  index.php?_search =您在找什么? (我删除了%20)

我更喜欢URL

  index.php?do = search& _search =您在找什么? 

是否最好在表单中添加一个隐藏字段

 < input type ='hidden'name ='do'value ='search'/> 


解决方案

在我看来,您应该将它们添加为隐藏字段。如果你可以通过隐藏的表单域来实现,那么没有必要尝试传递参数。



使用:

 < input type ='hidden'name ='do'value ='search'/> 


Is it okay or correct to put a url get parameter in a form action?

<form method='get' action='index.php?do=search'>
  <input name='_search' type='text' value='What are you looking for?'>
  <button type='submit'> Search </button>
</form>

When I submit the form the URL is changed to:

index.php?_search=What are you looking for? (I've stripped %20)

I'd prefer the URL to read

index.php?do=search&_search=What are you looking for?

Would it be best to add a hidden field into the form

<input type='hidden' name='do' value='search' />

解决方案

In my opinion you should add them as hidden fields. There is no point to try to pass params if you can do it via hidden form field

use that:

<input type='hidden' name='do' value='search' />

这篇关于将URL参数添加到表单PHP HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆