I am trying to save form data in Angular by ajax to store.php file. But, seems data is not properly fetched by file. Can someone point the mistakes?
<form id="form1" post="content/store.php">
<div class="form-group">
<label for="examplename">Name</label>
<input type="text" class="form-control" id="examplename" placeholder="Enter your name">
</div>
<div class="form-group">
<label for="exampleemail">Email</label>
<input type="email" class="form-control" id="exampleemail" placeholder="Enter your email">
</div>
<button type="submit" class="btn btn-default" ng-click="submitting()" >Submit</button>
</form>
ANGULAR SCRIPT:
var app = angular.module('myApp',[]);
app.controller ('myCtrl',function($scope, $http){
$scope.submitting = function(){
var request = $http({
method: "post",
url: "localhost/content/store.php",
data: {
email: $scope.email,
pass: $scope.password
}
});
request.success(function (data) {
alert("Successfully data entered! ");
});
}
});
STORE.PHP
<?php
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
@$email = $request->email;
@$pass = $request->pass;
echo $email;
?>