I am using $http through AngularJS to send data to a PHP document which is intended to save the data in a MySQL database. However, the data is being decoded blank or undefined. The JSON makes it to the PHP file, as I can see the request headers, but the response is blank.
I have tried testing different variations of the code to make sure that the JSON-encoded data makes it to the PHP document, and it does, but when attempting to json_decode()
it does not pull anything from the JSON.
PHP File
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$user = $request->Username;
echo $user;
AngularJS
$scope.submit = function() {
$http({
url: "http://www.walkermediadesign.com/planner3/src/ceremony.php",
method: "POST",
data: this.ceremony
}).then(function successCallback(response) {
console.log(response.data);
}, function errorCallback(response) {
$scope.error = response.statusText;
})};
This is the post data:
$postdata =
(2) [{…}, {…}]
0: {Username: "redphyre@gmail.com"}
1: {opening: "Friends and Family of BRIDE and GROOM, welcome and…d
falling in love with each other all over again."}
length: 2
__proto__: Array(0)
There are no error messages or 500 errors, just blank data being returned.