I just store the input data into the Local Storage. With $http.post I just get the data and post them to my backend.php
$scope.insertdata=function() {
$scope.stored = localStorage.getItem('todos');
$http.post("backend.php", {'dataTodos': $scope.stored})
.success(function(data,status,headers,config) {
console.log('Success!');
});
}
Here is my backend.php
$data = json_decode(file_get_contents("php://input"));
$storedTodos = mysql_real_escape_string($data->dataTodos);
mysql_connect("localhost", "root","");
mysql_select_db("div");
mysql_query("INSERT INTO ontodos(`todo`) VALUES('".$storedTodos."')");
The browser log (success), nothing else,
but my database is empty. Who is the error?? Hope anyone can help me.
mysql_error
to check whether or not the operation yielded some errors? Also, you probably shouldn't use the deprecated mysql.