Login with facebook account using php

Nowadays every website has the feature of social logins like Facebook, Twitter, Google Account and more. I got the lots of tutorial request to create a sample code to login with facebook account using the PHP. In this tutorial, I will explain how to log in with the Facebook account using PHP with example and you can also download the complete code. I have added the download link at the end of this tutorial.


Login with Facebook makes easy to connect with users or peoples using Facebook applications for your website. The Facebook SDK for Javascript provides a simple path to integrating users to log in to your websites.

It’s provides these common scenarios:

1) Your application uses Facebook Login to authorize users.
2) It’s also provides two login options: Facebook Login and your own website custom login.

Create Database Table

Sample users table columns id, email, and username.

Facebook Application Setup

Go to the https://developers.facebook.com/apps and create app id and app secret id, just modify in the following code

For the database configuration edit config.php

Create a config.php page and add below code after changing database configurations and save.

Integrate with your index.php page

If you want to change in your web application index page, just use following code.

Download the complete code from here


Thanks for giving your valuable time on FreeWebMentor community and follow on Facebook. If you still any question/queries please feel free to comment in below comment section. Do like & share with your friends if you like this post.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:

Article Tags: , , , , , , , ,