HTML Form
HTML Form application can be said to be an indispensable part of interactive web design. If it is just a simple corporate website, contact forms may also be used. Therefore, we have to spend some time studying the elements of HTML Form. We will design web pages in the future. It helps a lot. HTML form is composed of a set of <form></form>, which can contain various text input fields, menus and form buttons ( HTML button ). The simple form structure is as follows.
HTML form form structure
... form content...
</form>
Common HTML form form elements
1. Text input field <input type="text">
The input field of the form <input type="text">, such an input tag will An input box is displayed on the page, which is used to fill in information for netizens, such as the account password for member login or the name, phone number, and address of the online registration form.
2. Password input field <input type="password">
3. Text input field <textarea></textarea>
4. Drop-down menu <select><option></option></select>
<select></select> presents a drop-down menu of an HTML form. For example, date selection or shopping product specifications are common applications, where <option> is an option, which can be set For the options of the drop-down menu, each option gives a different value. After the form is sent, the program will get the user’s choice.
5. Option buttons Radio Buttons <input type="radio">
Radio Buttons <input type="radio"> are usually a set of options, so that netizens can only choose one of them , The trick to make a group is to set the name of the entire group <input type="radio"> to be the same, so that the form will automatically be judged as a whole group.
6. Checkboxes <input type="checkbox">
Checkboxes and radio buttons are used in different places. Checkboxes are usually used to make forms with multiple options. For example, when netizens fill in their personal interests, they can check many items. Checkboxes did it.
7, form button HTML button
After the above various form elements, the most important thing is to have a form button. As an important task for form sending, the form button button can be used as a form sending function In addition, you can also use JavaScriptCreate a function to clear the contents of the form!
8. Hidden fields input hidden
Hidden fields are used to pass some form parameters and will not be displayed on the web page.
HTML Form example
Name: <input type="text" name="UserName"><br>
Content: <textarea name="Content"></textarea><br>
<input type="submit" value="Submit Form">
</form>
content:
HTML Form form data transmission
After you have completed the design of the HTML Form form, the most important thing is of course the data processing after sending the form data. Usually we will use a programming language such as PHP to process and store it in the database, such as MySQL database. There are two ways to transfer HTML Form form data, namely POST and GET. The difference between the two methods lies in the URL parameters. If POST is used, the URL will not have parameters, but if GET is used, the form parameters will appear in the URL. Please refer to Examples of the following two delivery methods:
1. Send data through POST
<form action="PHP program to receive data" method="post"></form>
2. Transfer data via GET
<form action="PHP program to receive data" method="get"></form>
One of the important points here is that whether you use POST or GET, you must write lowercase English letters when writing the mothod in the form. If you write it in uppercase, it will cause problems! The most common problem is that PHP can't read the data, this should be a little bit careful.
Post a Comment
0 Comments