1

So, I'm currently using a Facebook login button API. What I wanted to do was for my code to add the user's email after the user logged in, into the SQL database. I'm having trouble understanding how to access the information of the email in the PHP code. This is all done on an HTML page but the HTML page doesn't hold variables and I tried running the javascript function to no avail. Part of my code is

 function returnEmail() {
    var url = '/me?fields=name,email';
    var email = '';
    FB.api(url, function(response) {
    console.log('Successful calls email function');
    email = response.email;   
    });
    return email;
 }

This essentially returns a string variable that represents the email value. I'm not familiar enough with PHP and how it interacts with Javascript to understand how I can get that email information and then add it. Thanks if you can provide any help!

3
  • 2
    PHP does not really interact with Javascript as PHP runs on the server and Javascript runs in the browser. By using Ajax you can send variables to php and receive the response, alternatively use php to generate javascript code/variables. Commented Jan 18, 2016 at 8:23
  • 1
    Possible duplicate of Data transfer from JavaScript to PHP Commented Jan 18, 2016 at 8:41
  • Thanks guys for the help! I used Ajax to do this Commented Jan 29, 2016 at 19:43

0

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.