So my problem is sending data to server with angular and post method with PHP. On the server side when submit button is clicked, and it adds, new ID as primary key. But value from input is not send. Thanks for help.
My html file
<h1>{{name}}</h1>
<h1 id="number" ng-click="getNumber(1)">0</h1>
<form on-submit="addNew()">
<input type="text" ng-model="formModel.text" id="text" name="text"/>
<button ng-click="addNew()">Add new text</button>
</form>
Angular file
app.controller('newCtrl', ['$scope','$http',function($scope,$http){
$scope.name = "Nikson";
document.getElementById('title').style.display = "none";
$scope.formModel = {};
$scope.addNew = function() {
console.log("Submited");
console.log($scope.formModel);
$http.post('post.php', $scope.formModel).
success(function(data){
console.log("ok")
}).error(function(data){
console.log("err");
});
};
}]);
And finaly PHP file
$conn = mysqli_connect('localhost','nemkeang','nemkic23', 'recs');
if(!$conn)
die("Error");
$text = $_POST['text'];
$sql = "INSERT INTO images (text)
VALUES ('$text')";
if (!mysqli_query($conn,$sql)) {
die('Error: ' . mysqli_error($conn));
}
echo "success";
mysqli_close($con);