2

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.

1
  • Why aren't you using mysql_error to check whether or not the operation yielded some errors? Also, you probably shouldn't use the deprecated mysql. Commented Apr 8, 2016 at 10:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.