0
HTML · Forms & Inputs
New technique
Forms collect input
Want to know a visitor's name? Forge them a form.
Search boxes, logins, sign-ups: they're all forms. A <form> wraps a group of fields and a button. When the button is pressed, the browser gathers what was typed and sends it off.
action says where the data goes (an address on the server), and method="post" sends it inside the request instead of in the address bar.
<form action="/join" method="post"> <input name="smith" type="text"> <button type="submit">Join the forge</button> </form>
<button type="submit">sends the form it sits in.- Fields outside the
<form>are not sent with it.