PHP如何能够读取输入字段的ID? [英] How can an id of input field can be read by PHP?
问题描述
我有一个HTML输入字段,并且每个输入字段都用某个id指定,现在我怎样才能使用这个输入字段id来识别字段。
示例:
< input type ='text'id ='float'name ='attributename'value =''maxlength = '30'/>
我需要验证float的输入字段的id,然后将输入字段的值插入到db特别是外地。
请帮我解决问题。
它取决于您使用哪种方法传输数据(由表单
元素的方法
属性指定) p>
例如与:
< form method =POST>
< input type ='text'id ='float'name ='attributename'value =''maxlength = '30'/>
< input type =submit/>
< / form>
您可以通过 $ _ POST ['attributename']访问PHP中的数据
提交表单时。 $ _ POST
是一个关联数组,通过POST请求保存数据。
$ b 注意: input元素的 name
是重要的属性,而不是ID。该ID不是传输到服务器,它只在DOM中扮演角色。只有名称
和值
被发送到服务器。因此,如果您想设置 name =float
。
更多信息: 外部源变量 。您也可以阅读 $ _ POST
和 $ _GET
(GET是另一种方法,用于通过URL发送数据)。
I have an HTML input field, and I have every input field specified with some id, now how can I use this input field id to identify the field.
Example:
<input type='text' id='float' name='attributename' value='' maxlength='30'/>
I need to verify the id of input field for float and then insert the input field's value in to db in particular field.
Please help me out..
It depends which method you use for transferring the data (specified by the method
attribute of the form
element).
E.g. with:
<form method="POST">
<input type='text' id='float' name='attributename' value='' maxlength='30'/>
<input type="submit" />
</form>
you can access the data in PHP via $_POST['attributename']
when the form is submitted. $_POST
is an associative array that holds the data send via a POST request.
Note: The name
of the input element is the important property, not the ID. The ID is not transferred to the server, it plays only a role in the DOM. Only the name
and the value
is send to the server. So if you probably want to set name="float"
.
Further information: Variables From External Sources. You also might want to read about $_POST
and $_GET
(GET is the other method. This is used to send data via the URL).
这篇关于PHP如何能够读取输入字段的ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!