Angularjs Post submit Chinese garbled?

Source: Internet
Author: User
Tags sha1
Html:

    

Php:


  
   prepare($sql);    $sth->bindParam(':username', $user_name);   // $sth->bindParam(':pwd', $up);    $sth->execute();    $rs = $sth->fetchAll(PDO::FETCH_ASSOC);      return $rs;}?>

Received user_name is garbled, here is the need to set the post headers? How it should be set.
For a variety of reasons, you need to maximize compatibility with previous systems, so use gb2312.

Reply content:

Html:

    

Php:


  
   prepare($sql);    $sth->bindParam(':username', $user_name);   // $sth->bindParam(':pwd', $up);    $sth->execute();    $rs = $sth->fetchAll(PDO::FETCH_ASSOC);      return $rs;}?>

Received user_name is garbled, here is the need to set the post headers? How it should be set.
For a variety of reasons, you need to maximize compatibility with previous systems, so use gb2312.

Can I paste the HTTP message of the POST request,

Should be able to receive the first time to receive with UTF-8, and then to store or interact with other services on the server to gb2312, usingiconv()

@ Li Mingxing engraved with blog post Http://blog.csdn.net/vera_xue ...

I used the following code in PHP to solve the problem:
$params = Json_decode (file_get_contents (' Php://input '), true);
Require ("cfg.php");
Global $DBH;
$user _name = $params ["uname"];//utf-8
$user _name = Iconv ("UTF-8", "GB2312", $user _name);

  • Related Article

    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.