';"."/> ';".">

Home  >  Article  >  Backend Development  >  What to do if PHP passes garbled post parameters

What to do if PHP passes garbled post parameters

藏色散人
藏色散人Original
2022-11-03 09:06:031545browse

Solution to the garbled post parameter passed by php: 1. Open the corresponding source code file; 2. Find "$_POST["pro_name"]"; 3. Change "header("Content-Type:text/ html;charset=utf8");" can be changed to "echo'c014038dc7c13fc2826e15efd7a2a216';".

What to do if PHP passes garbled post parameters

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

What should I do if PHP passes garbled post parameters?

Problem description:

PHP $_POST submits Chinese garbled characters

html:

{$pro_name}

价格:¥{$pro_price}

已售出:{$pro_sale}件 数量
action: public function add(){ $user = session("user_name"); if(session("user_name")){ header("Content-Type:text/html;charset=utf8"); request.setCharacterEncoding("UTF-8"); $common = D("Common"); $data["user_id"] = $user[0]["user_id"]; $data["user_name"] = $user[0]["user_name"]; $data["pro_id"] = $_POST["pro_id"]; $data["pro_name"] = $_POST["pro_name"]; $data["pro_price"] = $_POST["pro_price"]; $data["pro_num"] = $_POST["pro_num"]; $data["pro_total"] = $_POST["pro_num"]*$_POST["pro_price"]; dump($data); echo $data["pro_name"]; } }

Why is the received $_POST["pro_name"] garbled? I have checked the source code of the page and the hidden field has not become garbled

Solution:

header("Content-Type:text/html;charset=utf8");

is changed to

echo '';

Recommended study: " PHP video tutorial

The above is the detailed content of What to do if PHP passes garbled post parameters. 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