SyntaxError: Unexpected token C in JSON at position 0 in Ionic

I want to save data to MySQL using AngularJS.But I ran into a problem and did not.Adding data is happening.Also a blank line is added at the same time.Blank line first, then the data.


<ion-view view-title="Dashboard">
 <ion-content class="padding"> 
  <form ng-submit="submit()">
     <div class="list">
        <label class="item item-input">
              <span class="input-label">Name</span>
              <input type="text" ng-model="">
        <label class="item item-input">
             <span class="input-label">Surname</span>
             <input type="text" ng-model="data.surname">
        <label class="item item-input">
             <span class="input-label">Mail</span>
             <input type="text" ng-model="data.mail">
    <button class="button button-block button-positive" button class="button button-block button-positive" ng-click="submit()">


angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope,$http) {
  $ = {};

 $scope.submit = function(){      
      $"http://localhost:8080/insert.php", {
        'name' : $,
        'surname': $,
        'mail' :  $ 
            console.log("Data Inserted Successfully");
            alert("Sorry! Data Couldn't be inserted!");





header("Content-Type: application/json; charset=UTF-8");
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');

 $servername = "localhost";
 $username = "root";
 $password = "";
 $dbname = "ionic";

$conn = new mysqli($servername, $username, $password,$dbname);

$data = json_decode(file_get_contents("php://input"));

  $ad = $data->ad;
  $soyad = $data->soyad;
  $mail = $data->mail;

// Create connection

 // Check connection
 if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
    echo "Connected successfully";

   $sql = "INSERT INTO user (ad,soyad,mail)
     VALUES ('".$ad."','".$soyad."','".$mail."')";

       if ($conn->query($sql) === TRUE ) {
        echo "New record created successfully";
    } else {
          echo "Error: " . $sql . "<br>" . $conn->error;



I’m waiting for your help