Login/ Register With Facebook

social media

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

Step1:

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

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

<script>
window.fbAsyncInit = function() {
    FB.init({
       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 + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());

function fblogin(){
FB.login(function(response){
if (response.authResponse) {
window.location='validatefb.php';
}
},{scope: 'publish_stream'});
}
</script>

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" 
style="cursor:pointer">
The above code will open a popup to login with Facebook.

Login with Facebook

Step3:

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.

You can download the Facebook login file in zip format from here.

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 .

register_fb.php: New user will redirect to this page where they can register. You can use your own registration form.

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.
 

Other Login/ Registration Systemss

Login/ Register With Twitter
Login/ Register With Linked In
Login/ Register With Yahoo!
Login/ Register With Gmail
Login/ Register With Hotmail
Login/ Register With Email

Download Code Files Total Downloads: 19026

Comments
28 February
2014
thepriandana
what the sql source for database?
27 February
2014
Dan
I've looked at all of your different login code pages, do you have a master login script? One that ties them all together?

D
04 January
2014
nasir
hi
02 January
2014
kamran

Friend
21 December
2013
saurav daga
Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in /home/sau3334/public_html/facebook_login/facebook/facebook/base_facebook.php:19 Stack trace: #0 /home/sau3334/public_html/facebook_login/facebook/facebook/facebook.php(35): require_once() #1 /home/sau3334/public_html/facebook_login/facebook/facebook_constants.php(5): require('/home/sau3334/p...') #2 /home/sau3334/public_html/facebook_login/facebook/validatefb.php(4): include('/home/sau3334/p...') #3 {main} thrown in /home/sau3334/public_html/facebook_login/facebook/facebook/base_facebook.php on line 19
09 December
2013
Soutam Saha
Its working fine now. nice work.
05 December
2013
Soutam Saha
It's working fine till the register_fb.php page.Its getting the token value from validatefb.php page and redirect to the register_fb.php with the token. After that its doing nothing. its showing the blank page. Please help.
03 December
2013
MS_xmas
so helpful!!! thank u!
03 December
2013
Ramin
Good job buddy
05 November
2013
naynaygohard
help please
16 October
2013
Hussain
Thanks
comments powered by Disqus