';" to the head of the code to solve the problem of submitting data Garbled code problem."/> ';" to the head of the code to solve the problem of submitting data Garbled code problem.">

Home  >  Article  >  Backend Development  >  PHP $_POST submission form Chinese garbled problem

PHP $_POST submission form Chinese garbled problem

卡哇伊
卡哇伊Original
2020-07-06 11:47:463951browse

PHP $_POST submission form garbled solution is to add "echo 'c014038dc7c13fc2826e15efd7a2a216 in the head of the code ';" can solve the problem of garbled submitted data.

PHP $_POST submission form Chinese garbled problem

Problem details:

Set the header on the submission page08981208cd63613d2f3702fa28eeff2e, and make sure that the editor saves the utf-8 display page and also adds the html header.

echo &#39;<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">&#39;;

Solution:

The front-end calls the interface, and the back-end receives the data and saves the database. Note that contentType must be set like this:

 if(isSuccess){
               var token = sessionStorage.token;
               $.ajax({
                   type:&#39;post&#39;,
                   url:&#39;../../api/container/&#39;+token+&#39;/addContainerDamageReport&#39;,
                   contentType:&#39;application/x-www-form-urlencoded;charset=utf-8&#39;,
                   data:{&#39;containerName&#39;:&#39;HJSY&#39;+containerName,&#39;username&#39;:username,&#39;description&#39;:descript,&#39;damageTime&#39;:damageTime
                        ,&#39;reportTime&#39;:reportTime,&#39;damageLevel&#39;:badLevel,&#39;damageType&#39;:badType},
                   cache:false,
                   dataType:&#39;json&#39;,
                   success:function(data){
                    $(&#39;#submit&#39;).attr(&#39;data-dismiss&#39;,"modal");
                        console.log(data)
                   }
               })
           }

The backend accepts: The encoding format of the page is utf-8, and the SQL server database is gbk. Pay attention to the conversion, otherwise the insertion will be garbled.

More learning tutorials: PHP HTTP protocol video tutorial

The above is the detailed content of PHP $_POST submission form Chinese garbled problem. For more information, please follow other related articles on the PHP Chinese website!

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