Home > Backend Development > PHP Problem > What should I do if php cannot get the name?

What should I do if php cannot get the name?

藏色散人
Release: 2023-03-17 14:52:01
Original
1468 people have browsed it

php cannot get the name because when the name and id values ​​of the form element are different, the browser cannot recognize it. The solution: 1. Check whether some form elements and frame elements are used name; 2. Check elements that can only be assigned IDs but not names; 3. For multi-select box checkboxes, you can use "join(',', $__POST['name'])" to form data.

What should I do if php cannot get the name?

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

What should I do if php cannot get the name?

PHP form element NAME and ID acquisition problem

When the name and id values ​​​​of the form element are different, the browser cannot recognize it, but only when their values ​​​​are the same Only then can he be ready to find it.

The name and id of the form are actually used to mark the object name.

The difference between them is: the name is Netscape's and the id is Microsoft's. In order to be compatible, it is understandable that name and id must be set to the same! The id is like a person's ID number, and the name is his name. Obviously, the id cannot be repeated, but the name can be repeated. Only elements with name are received on the receiving page of the form. For example: $__POST("aa"), where aa is the name attribute value of an element in the submitted page. So what is received through the form is not the id value, but the name value.

Summary:

1. Use name for form elements (form input textarea select) and frame elements (iframe frame).

2. Elements that can only be assigned ID but not name: (Except for elements related to the form, only ID can be assigned)

body li a table tr td th p div span pre dl dt dd font b and so on.

3. For the multi-select box checkbox, PHP obtains data in array form. Multi-select values ​​can be composed of data using join(',', $__POST['name']).

What is obtained through the ID is the first assignment.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if php cannot get the name?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template