I'm having a problem with getting data over to my PHP file after decoding Json and I am getting an error. Can someone help me to know where I am going wrong?
app.js
$scope.formPost = function(){
$http.post('sendmail.php',{msg: 'helo'})
.success(function(data,status,headers,config){
console.log('data: ' + data);
console.log('status: ' + status);
console.log('headers: ' + headers);
}).error(function(data,status,headers,config){
});
};
sendmail.php
$data = json_decode(file_get_contents("php://input"), true);
$msg = $data->msg;
echo $msg;
And the error message I'm getting is
Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/my-new-project/sendmail.php on line 5
Any thoughts?