fastread homefastrread library fastread menu

PHP Tutorial : Login/ Register With Facebook

Tutorial by:Admin      Date: 2016-04-14 02:01:19

❰ Previous Next ❱

Now a days most of the project required login through social media. This article will guide you to crate login/ register with Facebook.


Please insert the Following script inside body tag of your login/register page.

<div id="fb-root" style="float:left; width:1px;"></div>

window.fbAsyncInit = function() {
       appId: 'Enter your API here',
       cookie: true,
       xfbml: true,
       oauth: true

(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//';

function fblogin(){
if (response.authResponse) {
},{scope: 'publish_stream'});

Click here to know more about Permissions in Facebook.

Click here to generate App ID/API Key and App Secret for Facebook.

Step 2:
Please insert login with face book button and write down the following code.

<img border="0" src="images/login_facebook.png" onClick="fblogin();" border="0" 

The above code will open a popup to login with Facebook.

Login with Facebook


validatefb.php  will check if the user has already register with your system or not. If the user registered before then the system will take the user to welcome page or it will take the user to register page.

File Included in this projects are:

connection.php: This is the simple database connection file. You can use your own database connection file.

facebook_constants.php: This is the file you need to change and use your own API key and secret key.
Click here to know how to generate API key and Secret id .

❰ Previous Next ❱

PHP Tutorial

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website