Home > Article > Web Front-end > How to create a form using HTML to send
In addition to the language for displaying characters and images, HTML actually also has the function of creating simple forms. This article will share with you how to use HTML format to create a sending form.
Let’s first explain the form elements: The form element is a necessary element to create a submission form.
The basic format is as follows:
<form action =""method =""> //填写表单的内容 </ form>
In fact, although it does not display an input form that only uses form elements for imaging, it can be done by placing such input attributes in the form section to display the form.
The form element is an image, such as a label for sending an order by putting parts together.
Having said this, the form may still not be clear enough. Let’s take a look at the specific content.
action attribute
The action attribute is used to specify the location where the data is sent after the form is sent.
Example:
Specified as an external URL
We send the form data to the URL (http://www.php.cn/)
<form action ="http://www.php.cn/">
Specified as an internal URL
Send form data to form.php for processing at the location added to the end of the current URL.
<form action ="form.php">
Unspecified
Send form data to the current URL.
<form>
method attribute
Specify the role of the method attribute and the sending method when sending the form.
Common transmission methods are POST and GET.
Let’s look at a specific example
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <form action="" method=""> <div> <label for="message">message:</label> <br> <input type="text" /> </div> <div class="button"> <button type="submit">发送消息</button> </div> </form> </body> </html>
The effect is as follows:
Explanation: In the above code, form is a Large label; below is label, which can be set on the form. This time, a message label is generated. Next is the input tag, which can be used to generate input forms; and finally button, which is a tag that can generate buttons.
The above is the detailed content of How to create a form using HTML to send. For more information, please follow other related articles on the PHP Chinese website!