okay good evening
i been having problems recieving data from http request from a C++ program
I use Wininet
InternetOpenA()
InternetConnect()
HttpOpenRequest()
HttpSendRequest()
now the good news is it sends the program to the php file, now no worries all work fine there
when i do a code like this to get the POST data
<?php
$data = file_get_contents(php://input);
$fp = fopen("log.txt","a+");
fwrite($fp,$data);
fclose($fp);
?>
it gets the data and saves to text file. but when i do the following
<?php
$data = urldecode($_POST['info']);
$fp = fopen("log.txt","a+");
fwrite($fp,$data);
fclose($fp);
?>
it just creates the log.txt and doesnt save any data inside it. Started to think this is a php problem, but every thing i tried just fails... what could be wrong?
From experience, fopen has caused alot of errors for me, it just doesnt always work with certain aspects. Create a mysql database and save the log data there and you can create a page/ connect to it with your C++ program to get the logs.
If you get data from php://input
, but $_POST
is empty, then your POST data is NOT in key=value
format. If PHP can't find any key=value
data, then it can't build $_POST
for you. $_POST is an array like any other, and all data going into it MUST have a key. No key, no array entry.