HTML form

What is a form

##The form is to collect different types of user input, such as:

  • Website registration

  • Login

  • Post resume

  • Forum post

  • Reply S vote etc


##HTML Form

A form is an area containing form elements. A web page may have multiple forms, but a form corresponds to a form area, and can only submit the form items of the current form area.

The form element allows the user to enter content in the form, such as: text area (textarea) , drop-down lists, radio-buttons, checkboxes, etc.

The form uses the form tag

to set:

##

.input element


actionis used to configure where the form data is sent for processing. It is usually the address of a dynamic script, such as the address of a PHP file. login.php

methodcan be GET or POST (if not set, the system defaults to GET, but in most cases We use POST and GET to submit in the form of parameters. Users can directly see the submitted parameters. Post uses the HTTP post mechanism to place each field in the form and its content in the HTML HEADER and transmit it to the URL address pointed to by the ACTION attribute. Can't see this process)


##HTML Form - Input Element

The form tag used in most cases is the input tag ().

The input type is defined by the type attribute (type). The most frequently used input types are as follows:

Text field

The text field is set through the tag. When the user types letters, numbers, etc. in the form, the text field is used.

Example

    php中文网(php.cn) 
文本域:
文本域:

The browser displays the following:

7.jpg


Password field

##The password field is defined by the tag :

    php中文网(php.cn) 
姓名:
密码:

The browser displays as follows:

1.jpg

Note: Password field characters will not be displayed in plain text, but will be replaced by asterisks or dots.


Radio button

## tag defines the form radio button Options

    php中文网(php.cn) 

The browser displays the following:


Checkbox

defines a checkbox. The user needs to select from a number of given Select one or several options from the selection.

    php中文网(php.cn) 
自行车 汽车 飞机 轮船

The browser displays as follows:

9.jpg


##Submit button

defines the submit button.

When the user clicks the confirm button, the content of the form will be transferred to another file. The form's action attribute defines the file name of the destination file. The file defined by the action attribute usually performs related processing on the input data received. :

    php中文网(php.cn) 
用户名
密 码

The browser displays as follows:

4.jpg

#If you type a few letters in the text box above and then click the confirm button, the input data will Sent to the "action.php" page as a post. This page will display the entered results.


HTML form tag

Tags Description
Define the form for user input
Define the input field

Program running result:

18.jpg


##Form instance

28.jpg



Example

2.jpg



Continuing Learning

About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!
## < datalist> This example demonstrates how to add a form to the page. This form contains an input box, a text field, radio buttons, check boxes, drop-down lists and a confirm button.
    php中文网(php.cn) 
作者:
文本内容:


Program running results:#Click the "Submit" button, and the form data will be sent to the form.php page in the form of a postThis example demonstrates how to send an email from a form.
    php中文网(php.cn) 
姓名:

E-mail:

你的意见:

Program running results:#Click the "Submit" button, the form data will be sent to the form.php page in the form of a post, click "Reset" ” button will clear the content you entered.
||
php中文网(php.cn)
姓名:

E-mail:

你的意见:

submit Reset Code
Define a click button
Specifies a predefined input control option list
Defines the key pair generator field of the form
Define a calculation result