Ionic login php + token

Hi guys,

I’m following this tutorial written by Mr Simon about create a login.
But I’m facing a problem when I want it to check the credentials stored in a database with php.

I modified the services.js to check, but I can figure out what is wrong!
Please I need your help, i’m stuck on this…

Here is the code I modified in service.js:

  var login = function( name, pw) {
       $rootScope.rsJSON = [ ];
       var req = {
     method: 'POST',
     url: 'http://localhost/test/index.php',
     headers: {
       'Content-Type': undefined
     data: { usuario : name , contrasena : pw },
     dataType: "jsonp"

        .success(function(data, $state) {
    return $q(function(resolve, reject) {
      if (typeof(data.USUARIO) == "undefined") {
        // Make a request and receive your auth token from your server
         reject('Login Failed.');
      } else {
          storeUserCredentials(name + '.yourServerToken');
        resolve('Login success.');
        .error(function(data) {
            console.log('Error: ' + data);

I received the follow errors:

Include authService.js in index.html.

Hi @eivanov, I don’t understand your point, how can i include AuthService.js in index.html?
sorry if it is a stupid question, but i’m still learning this

The error that you receive is not located where they are calling the function is defined.

@leugim_ohlavrac You can add your js file

<script src="js/AuthService.js"></script>

Hi @sioesi, didn’t worked… the error still appearing

@leugim_ohlavrac You followed the tutorial at the foot dela letter? I’ll check it out!

yes, i followed and it works, but i want to change to work with a remote database, called by php… and i’m stuck on this point

Any tip please? This is important to my project

Nobody knows that?