';" to the head of the code to solve the problem of submitting data Garbled code problem."> PHP $_POST submission form Chinese garbled problem-PHP Problem-php.cn

PHP $_POST submission form Chinese garbled problem

卡哇伊
Release: 2023-03-02 06:22:01
Original
3895 people have browsed it

PHP $_POST submission form garbled solution is to add "echo ' 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 page, and make sure that the editor saves theutf-8display page and also adds thehtmlheader.

echo '';
Copy after login

Solution:

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

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

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!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!