Failed to submit the submit and garbled characters occurred when saving mysql in PHP.

Source: Internet
Author: User
Tags php form
In the middle of the night, I was bored with writing a PHP form test. After writing the code, I started the test and found that I couldn't submit it. After reading it for a long time, I didn't find the problem. Later I saw that I set the ID of a button to submit, for example: inputtypebuttonvalue: Submit idsubmit. The background tries to change the id to sub. The result is submitted successfully. This problem occurs for the first time. Note:

In the middle of the night, I was bored with writing a PHP form test. After writing the code, I started the test and found that I couldn't submit it. After reading it for a long time, I didn't find the problem. Later I saw that I set the ID of a button to submit, for example: input type = button value = submit id = submit. The background tries to change the id to sub. The result is submitted successfully. This problem occurs for the first time. Note:

In the middle of the night, I was bored with writing a PHP form test. After writing the code, I started the test and found that I couldn't submit it. After reading it for a long time, I didn't find the problem. Later I saw that I set the ID of a button to submit, for example:

,

The background tries to change the id to sub, and the result is submitted successfully. This problem occurs for the first time.
Note:After the original input button ID is set to submit, JS cannot control the form. submit () event.
After submission, go to the database to view the data and find that Chinese characters are garbled. To view the information, you need to set the encoding.
How to Set mysqli is::

$ Mysql = new mysqli ($ dbserver, $ dbusername, $ dbpassword, $ database );
$ Mysql-> query ("set names utf8 ");

Mysql also has a query function mysql_query ($ db, "set names utf8 ″);

Topics you may like

Original article address: the submission of the submit failed and the mysql saving in PHP encountered garbled code. Thank you for sharing it with the original author.

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.