What should I do if php cannot accept the post information?

hzc
Release: 2023-03-01 13:36:02
Original
2915 people have browsed it

What should I do if php cannot accept the post information?

Solution to the problem that php cannot accept post information:

This usually occurs when submitting ajax

When we set the ajax parameter contentType: 'application/json; charset=utf-8', we use file_get_contents("php://input") to get the value $_POST, which cannot be obtained.

1. Check the header The information content-type is "content-type:application/x-www-form-urlencoded". This transmission is to submit data in a form and PHP uses the $_POST method to accept it.

2. Check whether the header information content-type is "content-type:application/json". This kind of transmission submits data in json mode. PHP needs to use file_get_contents("php://input") to obtain it. The input stream method accepts

recommended tutorial: "php tutorial"

The above is the detailed content of What should I do if php cannot accept the post information?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template