I posted a variable from a angularjs controller to a php file in the same folder using $http.post() method. But in the php page I am able to retrieve the variable. The variable is being undefined.
Here is the angular code
$scope.checkout = function(){
$http({
url:"checkout.php",
method : 'POST',
data :{
'total':$scope.total
},
headers : {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}
}).success(function(data, status, headers, config) {
window.location.href = 'checkout.php'
}).error(function(data, status, headers, config) {
console.log("not done");
});
}
and here is the php code
<?php
$_SESSION['bill_amount'] = $_POST['total'];
echo $_SESSION['bill_amount'];
?>
But I am getting the error that total is undefined.