PHP form submission Control name contains the dot (.) will be converted into an underscore (_) Processing Method

Source: Internet
Author: User
Tags php form

Recently, when I was working on a company project, I found a strange problem. When I submitted a normal form, I found that the submitted value could not be obtained normally, I was confused at the beginning. At the beginning, I thought it was a problem with my service and could not normally write data into the database. Later I detected SQL statements and found that, the original problem occurred when obtaining data, and the obtained data was empty. Later, a debug found that all the variables originally submitted to the backend were no longer the expected variables, it turned out to be converted by PHP.

The test code is as follows:
Copy codeThe Code is as follows:
<Html>
<Head>
<Title> test form submission </title>
</Head>
<Body>
<Form action = "" method = "post">
Name: <input type = "text" value = "test" name = "info. name"/> <br/>
Password: <input type = "text" value = "hahaha" name = "info. pwd"/> <br/>
QQ: <input type = "text" value = "961412" name = ". info. qq"/> <br/>
Address: <input type = "text" value = "zhejiang" name = "info | address"/> <br/>
Tel: <input type = "text" value = "123456789" name = "1 -- phone"/> <br/>
Gender: <input type = "radio" name = "info_gender" value = "1" checked> male <input type = "radio" name = "info_gender" value = "2"> female <br/>
<Button type = "submit" name = "submit" value = "> commit </button>
</Form>
</Body>
</Html>
<? Php
If ($ _ POST ){
Echo '<pre/> ';
Var_export ($ _ POST );
}
?>

Code example 1
The result is as follows:

Figure 1

As you can see, all. are converted into _ underscores by the backend. In order to test other symbols, the above test has been conducted. So far, only the dot (.) has been found (.) will be converted to underscores (_), so I take info for granted at the backend. name cannot be accessed because it has been converted into info_name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.