Home  >  Article  >  Backend Development  >  How to deal with PHP form submission control names containing dots (.) that will be converted into underscores (_)_PHP Tutorial

How to deal with PHP form submission control names containing dots (.) that will be converted into underscores (_)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:13:48953browse

Recently, when I was working on a company project, I discovered a strange problem. When I submitted a normal form, I found that the submitted value could not be obtained normally. This discovery made me confused at first. At first, I thought it was me. There was a problem with the service and it could not be written to the database normally. Later, after detecting the SQL statement, it was found that the problem actually occurred in obtaining data, and the obtained data was all empty. Later, after debugging, it was discovered that all the variables submitted to the backend were , are no longer the expected variables, but have been converted by PHP.

The test code is provided as follows:

Copy the code The code is as follows:

< ;html>

Test form submission



Name:

Password:

QQ:

Address:

Phone: < ;input type="text" value="123456789" name="1——phone" />

Gender: MaleFemale





if ($_POST) {
echo '
'; 
var_export($_POST);
}
?>

Code Example 1
The result after running is as follows :
How to deal with PHP form submission control names containing dots (.) that will be converted into underscores (_)_PHP Tutorial
Figure 1

As you can see, all the . symbols I included in the control were converted into _underscores by the backend. In order to test some other symbols, so After doing the above test, so far, I have only found that the dot (.) will be converted into an underscore (_), so when I use info.name to access the backend, I can't find it because it has actually been used. Converted into info_name.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326395.htmlTechArticleWhen I was working on a company project recently, I discovered a strange problem. I submitted a normal form, but found that it could not be obtained normally. To the submitted value, this discovery inevitably made me start...
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