Hi,
I've created my own custom application in PHP and 2 hours ago sent it to my OVH hosting catalog. Ever since then it's been nothing but problems.
My frontend sends to the backend data from a form in the following way with jQuery:
let formData = $('#token-form').serialize();
var requestForTokens = $.ajax('file.php', {
method: 'post',
data: formData,
contentType: "application/json",
dataType: "json",
encoding: "text/plain"
});
(there's only one input named "access-token")
On the backend I have the following code to verify incoming data:
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$postData = json_decode(file_get_contents('php://input'), true);
$token = $postData['access-token'] ?: null;
if (empty($token)) {
http_response_code(401);
$response['error_message']='Token cannot be empty';
//much more code later
Of course every request ends up with the empty token message.
Before I didn't have the 'contentType: "application/json"' in my ajax request and I was just using "$_POST['access-token']" to get contents of the incoming data, but the the server always responded with 400.
Please help. On my xampp localhost it worked perfectly, no problem. With OVH I constantly stumble upon every possible error.
Web Hosting - PHP cannot read incoming post data
Related questions
- Update MySQL Version
12545
14.02.2018 03:27
- How do I limit upload_max_filesize? PHP.ini method not working
12284
06.12.2022 11:02
- Max_execution_time how to increase time
12164
24.01.2021 17:14
- Connect to mysql database
12018
28.02.2018 16:52
- I can't login to my account. Reset password don't help
11499
25.02.2020 22:06
- Layer 7 DDoS protection on Web hosting
11017
17.08.2025 13:59
- Cannot put SSL on my domain
10983
03.04.2019 19:20
- Abuse Report not working
10327
27.03.2025 07:45
- How do I get rid of the default 'site under construction' page?
10054
27.10.2022 14:35
- Trying to connect my OVH domain to shopify store
9200
13.06.2021 22:43