I am trying to send values from AngularJS to PHP like below

loginService.js

'use strict';

app.factory('loginService',function($http){
   return{
       login:function(user){
                var promise = $http.post('data/user.php',user); //send
data to user.php
                promise.then(function(msg){
                    if(msg.data=='succes') console.log('succes login');
                    else console.log('error login');
                })
       }
   }});

My PHP file is like below

user.php

<?php
    $user=json_decode(file_get_contents('php://input'));

    if($user->mail=='[email protected]' && $user->pass=='1234')
    {
        print 'succes';
    }
    else
    {
        print 'error';
    }
 ?>


My output is like below

error login


loginCtrl.js

'use strict';

app.controller('loginCtrl',function($scope,loginService){
    $scope.login=function()
    {
    loginService.login();
    }})

How can I debug here ?? Like, is php file getting values ?? is php file
sending values ??

Could anyone say where is my mistake??

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to