Cannot post myfirstionic/login_service.php. My connection is working well.. Can anyone help me about this error? Thank you

This is my code in my controller.js
.controller(‘loginCtrl’, function($scope,$http, $state) {
//Variables
$scope.loginInfo = {
username: undefined,
password: undefined
}

var result = {
    test: undefined
}

result.test = {
    test: "test",
    test2: "test2",
    test3: "testers"
}

result.test = JSON.stringify(result.test);
//function
$scope.loginUser = function () {
     var data = {
        username: $scope.loginInfo.username,
        password: $scope.loginInfo.password
    }
    
    $http.post("myfirstionic/login_service.php", data).success(function(response){
        console.log(response);
        localStorage.setItem("token", JSON.stringify(response));
        $state.go("welcomePage", result);
    }).error(function(error){
        console.error(error);
    });

}

})

and for my login.php

<?php header("Access-Control-Allow-Origin: *"); require_once('connection.php'); $data = json_decode(file_get_contents("php://input")); $password = sha1($data->password); $username = $data->username; $userInfo = $db->query("SELECT email FROM users WHERE email='$username' AND password='$password'"); $userInfo = $userInfo->fetchAll(); $token; if (count($userInfo) == 1){ //This means that the user is logged in and let's givem a token :D :D :D $token = $username . " | " . uniqid() . uniqid() . uniqid(); $q = "UPDATE users SET token=:token WHERE email=:email AND password=:password"; $query = $db->prepare($q); $execute = $query->execute(array( ":token" => $token, ":email" => $username, ":password" => $password )); echo json_encode($token); } else { echo "ERROR"; } ?>

You shouldn’t be storing plaintext passwords in your database, and you also shouldn’t be reinventing the wheel by designing your own authentication token system. Use a standard like JWT.