I have a simple form with two fields.
<form name="save" ng-submit="sap.saved(save.$valid)" novalidate>
<div class="form-group" >
<input type="text" name="name" id="name" ng-model="sap.name" />
</div>
<div class="form-group" >
<input type="email" name="email" id="email" ng-model="sap.email" />
</div>
<div class="form-actions">
<button type="submit" ng-disabled="save.$invalid || sap.dataLoading">Save</button>
</div>
</form>
I'm trying to post these values to a php page using POST request.
$http({
method: 'post',
url: 'save.php',
data: $scope.vm,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
})
.success(function(data, status, headers, config)
{
if(data.success)
{
alert('valid');
}
else
{
alert('invalid 1');
}
}).
error(function(data, status, headers, config)
{
alert('invalid 2');
});
And in save.php file, I'm fetching the values like this:
$name=$_POST['name'];
$email=$_POST['email'];
But response I get is undefned variable name. That's a PHP notice. But when I try to POST these values from POSTman client, it works. Is there anything wrong with the method I choose to POST data?
P.S: i didn't post entire controller. Just http request part is included here.