Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
658 views
in Technique[技术] by (71.8m points)

html - Are <input> fields without a name attribute submitted to the server?

Lets say I have two input fields inside a form, like so.

<form class="my-form" method="POST" action="/my/receiver">
    <input id="input1" name="inputfield1" />
    <input id="input2" placeholder="More input" />

    <input type="submit" value="Submit form" />
</form>

If I am running a server that will listen to a form submission on that link, I know for a fact that #input1 will be sent to the server as data. However, since #input2 does not have a name, will this be sent to the server?

If you answer yes / no, is this standard HTML/HTTP behavior? Can I rely on this in a production application?

Note: I'm asking this question because I do not want some info sent from my form (due to security and liability reasons), and I want to ensure that it is not sent.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

An input element with no name is never submitted to the server.

That said, <input> is probably the wrong tool for the job if you specifically don't want it sent.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...