This example covers Facebook Login with the Facebook SDK for PHP. Example Although it's common to see examples of Facebook Login being implemented in one PHP script, is best to use two separate PHP scripts for more separation and more control over the responses.
Avoid Popup Blocking. Calling FB.login() results in the JS SDK attempting to open a popup window. As such, this method should only be called after a user click event, otherwise the popup window will be blocked by most browsers.