I am using Angular to send some json data to server. It gives me the entire php file as data in return.
On my bootstap modal I have ng-submit=createNewProgram()
$scope.createNewProgram = function()
{
var data = {
'programName': $scope.programName,
'startDate' : $scope.startDate,
'endDate' : $scope.endDate,
'startTime': $scope.startTime,
'endTime' :$scope.endTime
};`
$http({
method : 'POST',
url : 'curl.php',
data : data, //forms user object
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
})
.success(function(data) {
if (data.errors) {
// Showing errors.
$scope.message = 'wrong data';
} else {
$scope.message = data;
}
});
}
This is how I am recieving data through my php file (curl.php):
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
@$programName = $request->programName;
@$startDate = $request->startDate;
echo $programName;