0

Here is my app.js, I want to send the value of email to the file handler.php

$scope.doForget={email:''};
$scope.doForget = function (customer) {
     //email = $scope.forget.email; For Testing i am hardcoding the value
     email = '[email protected]';
     Data.post('handler.php', {
            email: email
        }).then(function (results) {
        console.log(results); 
        }); 
    };

In the Inspect Element -> Networks i can see the form values as {email: "[email protected]"}

In the handler.php i use to print the values by print_r($_POST); and even print_r($_GET); but i am always getting the empty array i.e.,

Array
(
)

How can i get the values ?

Update :

I even tried this one

$scope.doForget={email:''};
$scope.doForget = function (email) {
 email = '[email protected]';
 Data.post('eloquent.php', {
        email: email
    }).then(function (results) {
    console.log(results);
    });
};
14
  • How can you get it in networks when you didn't pass email into the post object 0.0? Commented Jul 2, 2015 at 4:46
  • Try post('eloquent.php', {emailNew : email}).then() Commented Jul 2, 2015 at 4:54
  • @Vineet I am getting ReferenceError: post is not defined error Commented Jul 2, 2015 at 4:57
  • Aren't you using $http service ? Commented Jul 2, 2015 at 4:58
  • Maybe you can try eliminate the possibility of Data.post not implemented correctly by replacing it with $http.post? Commented Jul 2, 2015 at 4:58

1 Answer 1

1

Just use in angular's controller :

var emailNew = "[email protected]";
  $http({
     method : 'POST',
     url : 'relative_path_to_demo.php',
     data : {"email" : emailNew}
  })

and in your server PHP file. Put code

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

$email = $objData -> email; // Get your email
Sign up to request clarification or add additional context in comments.

2 Comments

I am getting Object {data: "[email protected] ↵ ↵", status: 200, config: Object, statusText: "OK"}
Thanks, But why do i get this symbol ↵ ↵ ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.