Inserting data to mysql database from ionic app


#1

Hi there, i am so new in ionic and i have issue with the inserting data to mysql. I try to post data to my php file and insert into database but variables are empty always. First i want to write my codes.

This is my form codes :

  <form ng-submit="addfavourite()">
      <input type="text" ng-model="data.mac_id" ng-value="veri.mac_id">
      <input type="text" ng-model="data.user_id" ng-value="myuser">
      <input type="submit" value="" class="favourite">
  </form>

This is my controller codes :

$scope.data = {};

$scope.addfavourite = function(){
    
    var links = 'http://www.website.com/api.php';
    $scope.data.user_id = loggeduser;
    $http.post(links, {user_id : $scope.data.user_id, mac_id : $scope.data.mac_id}).then(function (res){
        $scope.response = res.data;
        if ($scope.response == 1) {
          $scope.messages = 'Correct.';
        }
        else if ($scope.response == 0)
        {
          $scope.messages = 'False.';
        }
    });
};

And this is my php codes :

$postdata = file_get_contents("php://input");
	if (isset($postdata)) {
		$request = json_decode($postdata);
		$user_mail = $request->user_id;
		$mac_id = $request->mac_id;
		
		
		$user_bul = mysql_query("SELECT * FROM table WHERE column = '$user_mail'");
		$user = mysql_fetch_assoc($user_bul);

		
		$count=mysql_num_rows($user_bul);
		
		
	$query = mysql_query("insert into table (column) values ('".$user_mail."')");



		if ($user_mail != "") {
			if ($count > 0) {
				echo "1";
			}
			else
			{
				echo "0";
			}
		}
		else {
			echo "Empty username parameter!";
		}
	}
	else {
		echo "Not called properly with username parameter!";
	} 

So when i checked query of $user_bul i can get correct data. And in my ionic app i can display my messages. But when i try to insert into database the fields are empty. Insert new line into database but fields are empty. So how can i add my datas into my mysql database?

Thanks to everyone to help.