Role:
To provide users with an interface (foreground interface), let users fill in the corresponding information, the user submitted information collected, categorized, and used to interact.
Workflow for forms:
1. Users fill in the data on the page with the form
2. Submit data to the backend (. php) For example uli.php
3, the background (. php) to verify after receiving data, if the validation passed, write to the database or read the data from the database, and then return to the client.
Syntax format:
<form property = "attribute value" >
???? <input type= "type of" >
</form>
????
Common Properties:
1. Action???????? Used to set up the form data processing page (. php)
2. Method???????? There are two ways to set up the submission method
Get???????? Default mode
Characteristics:
???? all data is passed in the form of a URL that is organized into a name-value pair .
???? Not safe
???? Single data type passed
???? Small amount of data passed
Post
Characteristics:
???? all data is passed within the protocol, organized into a name-value pair
???? Relatively safe
???? Various types of data passed
???? Large amount of data passed
3, enctype???????? Used to set how data is passed (optional) (this property is only valid if the method property is set to post)
Value:
1, Application/x-www-form-urlencode???????? (The default is this option, which you can not write by default) for passing text data
2, Multipart/form-data: If the form contains a control for file upload (input type= "file"), then this property value must be set to Multipart/form-data
Form elements
is to provide the user with an area to enter.
input type Control
???? Type: Set different types of form elements (input area)
?
Value:
- Text: Single-line textbox
???????? Role: To fill in the user name and other information, fill in some text information
Size: Controls how much text the input box displays and controls the width of a single line of text boxes
????
?
- Password????
• Control of information that is primarily used for inconvenient display of passwords , etc. · •
The text that we enter will be replaced with a representation of the solid origin, as shown.
?
- Radio???? radio button:
A group of radio buttons, the value of the attribute name of input must be consistent
Note: If you want to pre-set the display options, you can add a checked= "checked"
- CheckBox Check button
The properties of the input form are:
Type: set to checkbox
Attention:
A set of check buttons, all of the property values for the Name property are set to the same value, and you want to add a uniform after the property value of the property name to each []
?
?
?
- Submit????????
?
- File
Set up file uploads
<input type= "File" name= "UploadFile"/>
???? Type: Specifies the types of uploaded files, such as: type= "File"
???? Name: Specify the names of the elements
?
?
- Hidden????????
Not for users to fill in the input boxes or other options and other controls
The function is to set a hidden field, submit some data to the receiving program, pass some parameters
- Image???????? Used to set a picture submit button
Property Description:
Type: Set to Image
SRC: Introduce a picture resource that needs to be set
Width: setting widths
Height: Set height
Title: Setting the button's prompt information
- Reset????????
Reset button: function: If the user fill in the content is wrong to fill in the new, we have completed or selected content to initialize.
drop-down list
<select>
???? <option></option>
???? <option></option>
???? <option></option>
</select>
Note: If you want to change the options for the default presentation, add a property value to the option above that setting: Selected= ' selected '
<textarea></textarea> text fields:
COLS: Sets the number of columns to be merged, controlling the width of the text field
Rows: Sets the number of rows to be merged, controlling the height of the text field
Disabled: Property value: Disabled, if the value is set, the multiline text field is disabled:
Label Tags:
We can "bundle" Our text prompt information and our form control's input box into a whole, when we click on the content of the text section, we will select the default information which we have pre-filled in the prompt box.
The label triggers the form controls that are immediately adjacent to the text.
Label can be seen as a container
Writing one:
<form>
<lable for= Theattribute value of the id attribute of the input form > enter the user name:<lable>
<input type= "text" name= "username" id= "username" value= "Please enter user name"/>
</form>
Two:
<label> Enter user name: <input type= "text" name= "username" value= "Please enter username"/>
<label>
Form label elements