HTML表单方法问题 [英] HTML Form Method Problem

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

问题描述

<form name="frn" action="download.php?f=sample">
 <input type="submit" name="am" value="submit"/>
</form>



为什么将以上表格提交给以下人员?



Why the above form is submitted to following?

download.php



如果提到method =''GET'',为什么表格要提交给下面的人?



If method=''GET'' is mentioned, why the form submits to following?

download.php?am=submit



如果使用method ="POST",则只有它提交到原始操作字符串



if method=''POST'' is used, then only it submits to the original action string

download.php?f=sample



为什么?



Why?

推荐答案

您需要了解有关GET和POST方法的基础.
请在这里学习基础知识:

http://www.plus2net.com/asp-tutorial/form-diff.php [ ^ ]

http://www.cs.tut.fi/~jkorpela/forms/methods.html [ ^ ]
You need to know the basics about GET and POST method.

Please study the basics here:

http://www.plus2net.com/asp-tutorial/form-diff.php[^]

http://www.cs.tut.fi/~jkorpela/forms/methods.html[^]


其原因是表单标记的attribute方法的GET和POST的含义:

GET:
提交表单的所有数据都将被编码为URL参数
POST:
提交表单的所有数据都将发送到请求标头

这意味着将方法设置为 GET 时,将在URL附带的参数中发送值为"submit"的字段 am .如果方法设置为 POST ,则字段名称和值将在请求标头中发送,因此无需修改url.
实际上,没有理由尝试您所做的事情.如果要与其他表单数据一起提交一些其他参数,则可以仅包含一个隐藏字段:
The reason for this is the meaning for GET and POST of the attribute method of the form tag:

GET :
All data of the submitted form will be encoded as URL parameters
POST :
All data of the submitted form will be sent in the request header

That implies when you set the method to GET the field am with a value of "submit" will be sent in the parameters attached to the URL. If the method is set to POST the field names and values will be sent in the request header and thus the url will not have to be modified.
There actually is no reason to try what you did though. If you want some additional parameter to be submitted with the other form data you can just include a hidden field:
<input type="hidden" name="f" value"sample" />


字段f不会被显示,但是在提交表单时它将在请求中发送.
并且使用GET或POST方法都将产生预期的结果.

祝您编程愉快!

-MRB


Field f will not be diplayed, but it will be sent in the request when the form is submitted.
And using method GET or POST will both yield the expected results.

Cheers and happy coding!

-MRB


感谢你们俩.好的答复.
Thanks to both of you. Good replies.


这篇关于HTML表单方法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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