search
HomeWeb Front-endHTML TutorialHtml notes (7) form_html/css_WEB-ITnose

Form tag:

The form tag is the most commonly used tag and is used for interaction with the server side.

: Input tag; accept user input information

The type attribute specifies the type of input tag

Text box text: The input text information is displayed directly in the box. Password box password: The entered text is displayed in the form of dots or model numbers. Radio button radio: such as: gender selection. Checkbox checkbox: Such as: interest selection. Hidden field hidden: Not displayed on the page, but submitted with other content when submitted. Submit button submit: used to submit the content in the form. Reset button reset: Set the content filled in the form to the initial value Button button: You can customize events for it. File upload file: Later expanded content will automatically generate a text box and a button. Image image It can replace the submit button

for attribute: Specify the form element that the shortcut key works on. Must be the same as the id value of the form element to be applied.

accesskey attribute: Specify the shortcut key. This shortcut key needs to be used in combination with the alt key.

Example:

                  <p class="sycode">                      1      <     tr     >           2            <     td     ><     label      accesskey     ="u"      for     ="userid"     >     用户名     </     td     >           3            <     td     ><     input      type     ="text"      name     ="user"      id     ="userid"     /></     td     >           4            </     tr     >                  </p>

Form submission:

First define the action attribute value in the form form and specify the destination for form data submission (server) . Specify the submission method by specifying the method attribute value. If not defined, the value of method defaults to get.

The difference between the two most commonly used submission methods, get and post:

Get submission displays data in the address bar, which is not safe for sensitive information. Post submissions are not displayed in the address bar. The data stored in the address bar is limited, so the get method has limits on the volume of data submitted. Post can submit large volumes of data. The submitted data is encapsulated in different ways: get: The submitted data is encapsulated in front of the message header and in the request line. post: Encapsulate the submitted data into the data body after the message header. Note: Usually forms are submitted using post because coding is convenient. For the Tomcat server, the default decoding method is ISO8859-1, so Chinese characters will appear garbled. Submitted through post, you can use request.setCharcterEncoding("GBK"); to solve the garbled problem. This method is only valid for the data body. If it is submitted by get, request.setCharcterEncoding("GBK"); cannot solve the garbled problem and must be performed first. ISO8859-1 encoding, and then GBK decoding. Although this method is also suitable for garbled characters submitted by post, it is troublesome, so it is recommended to use post for form submission.

Example:

                  <p class="sycode">                       1      <     fieldset     >            2            <     legend     >     注册区域     </     legend     >            3            <     form      action     ="http://127.0.0.1:8888"      method     ="post"     >            4            <     table      border     ="5"      width     ="75%"      cellpadding     ="10"      cellspacing     ="0"      bordercolor     ="#3399FF"     >            5            <     tr     >            6            <     td      colspan     ="2"      align     ="center"     ><     b     >     信息注册页面     </     b     ></     td     >            7            </     tr     >            8             9            <     tr     >           10            <     td     ><     label      accesskey     ="u"      for     ="userid"     >     用户名     </     td     >           11            <     td     ><     input      type     ="text"      name     ="user"      id     ="userid"     /></     td     >           12            </     tr     >           13            <     tr     >           14            <     td     >     密码     </     td     >           15            <     td     ><     input      type     ="password"      name     ="passwd"     /></     td     >           16            </     tr     >           17            <     tr     >           18            <     td     >     确定密码     </     td     >           19            <     td     ><     input      type     ="password"      name     ="passwd_conform"     /></     td     >           20            </     tr     >           21            <     tr     >           22            <     td     >     性别     </     td     >           23            <     td     >           24            <     input      type     ="radio"      name     ="sex"      value     ="man"     />     男      25            <     input      type     ="radio"      name     ="sex"      value     ="woman"           />     女      26            </     td     >           27            </     tr     >           28            <     tr     >           29            <     td     >     技术     </     td     >           30            <     td     >           31            <     input      type     ="checkbox"      name     ="tech"      value     ="java"           />     Java      32            <     input      type     ="checkbox"      name     ="tech"      value     ="jsp"           />     Jsp      33            <     input      type     ="checkbox"      name     ="tech"      value     ="servlet"           />     Servlet      34            </     td     >           35            </     tr     >           36            <     tr     >           37            <     td     >     国家     </     td     >           38            <     td     >           39            <     select      name     ="country"     >           40            <     option     >     --选择国家--     </     option     >           41            <     option      value     ="cn"     >     中国     </     option     >           42            <     option      value     ="en"     >     英国     </     option     >           43            <     option      value     ="usa"     >     美国     </     option     >           44            </     select     >           45            </     td     >           46            </     tr     >           47            <     tr     >           48            <     td      colspan     ="2"      align     ="center"     >           49            <     input      type     ="submit"      value     ="submit"     />           50            <     input      type     ="reset"      value     ="reset"     />           51            </     td     >           52            </     tr     >           53            54            </     table     >           55            </     form     >           56           </     fieldset     >                        </p>

Security issues:

Violent submission, violent registration

                  <p class="sycode">                      1      <     a      href     =”http://注册地址?name=value&id=value......”     >     暴力开始     </     a     >                  </p>

Super By default, the link is submitted in the get method

The client first performs data validity verification, and the server must verify the data submitted by the client again

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are self-closing tags? Give an example.What are self-closing tags? Give an example.Apr 27, 2025 am 12:04 AM

Self-closingtagsinHTMLandXMLaretagsthatclosethemselveswithoutneedingaseparateclosingtag,simplifyingmarkupstructureandenhancingcodingefficiency.1)TheyareessentialinXMLforelementswithoutcontent,ensuringwell-formeddocuments.2)InHTML5,usageisflexiblebutr

Beyond HTML: Essential Technologies for Web DevelopmentBeyond HTML: Essential Technologies for Web DevelopmentApr 26, 2025 am 12:04 AM

To build a website with powerful functions and good user experience, HTML alone is not enough. The following technology is also required: JavaScript gives web page dynamic and interactiveness, and real-time changes are achieved by operating DOM. CSS is responsible for the style and layout of the web page to improve aesthetics and user experience. Modern frameworks and libraries such as React, Vue.js and Angular improve development efficiency and code organization structure.

What are boolean attributes in HTML? Give some examples.What are boolean attributes in HTML? Give some examples.Apr 25, 2025 am 12:01 AM

Boolean attributes are special attributes in HTML that are activated without a value. 1. The Boolean attribute controls the behavior of the element by whether it exists or not, such as disabled disable the input box. 2.Their working principle is to change element behavior according to the existence of attributes when the browser parses. 3. The basic usage is to directly add attributes, and the advanced usage can be dynamically controlled through JavaScript. 4. Common mistakes are mistakenly thinking that values ​​need to be set, and the correct writing method should be concise. 5. The best practice is to keep the code concise and use Boolean properties reasonably to optimize web page performance and user experience.

How can you validate your HTML code?How can you validate your HTML code?Apr 24, 2025 am 12:04 AM

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

HTML vs. CSS and JavaScript: Comparing Web TechnologiesHTML vs. CSS and JavaScript: Comparing Web TechnologiesApr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software