Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7529271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:36:57+00:00 2026-05-30T04:36:57+00:00

I am planning to integrate a Facebook Login button into my website. Right now

  • 0

I am planning to integrate a Facebook Login button into my website. Right now I have a Facebook Login button that when pressed, popups a new window asking for permission to access the user’s basic info and email. Everything done till now is from following http://developers.facebook.com/docs/guides/web/#login. I am using PHP (with Codeigniter framework, Tank auth authentication library) and jQuery.

Problem: Now after adding the login button to my website, Facebook no longer have any instructions on how to proceed?

  1. How do I retrieve the user’s information from facebook to insert into my database (if first visit)
  2. How do I determine that the user has allowed my website to access his information?
  3. If access has been granted, how do I redirect the user to a new page?

I understand there have been recent changes to the SDK, and googling for tutorials on it just gives me tutorials that says they are outdated. Any help to point me in the right direction will be greatly appreciated! Thanks!

HTML/JS

<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '123',
            status     : true, 
            cookie     : true,
            xfbml      : true,
            oauth      : true,
        });
    };
    (function(d){
        var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        d.getElementsByTagName('head')[0].appendChild(js);
    }(document));
</script>

<div id="splash_fbconnect_login_button" class="fb-login-button" data-scope="email, user_education_history, user_work_history"></div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:36:58+00:00Added an answer on May 30, 2026 at 4:36 am

    Quick edit: Go to https://github.com/facebook/connect-js make sure you have the latest version and use the PHP one, it makes it a hell of a lot easier i found.

    1) How do I retrieve the user’s information from facebook to insert into my database (if first visit)

    $user_profile['last_name'];
    $user_profile['first_name'];
    $user_profile['gender']; 
    

    etc.

    2) How do I determine that the user has allowed my website to access his information?

    The facebook API knows this, dont worry 🙂 as when the user clicks login a popup comes up (as you mentioned in your question) and when they click allow its done.

    One thing you must do however is create an App in facebook otherwise it wont work, im not sure if you have done this or not so go to https://developers.facebook.com/apps

    3)If access has been granted, how do I redirect the user to a new page?

    Javascript redirect in an if statement, this is what mine looks like

    Be sure to set some variables here too:

       <?php // Set the variables for the MVC
          $first_name = $user_profile['first_name'];
          $last_name = $user_profile['last_name'];
          $full_name = $first_name . " " . $last_name;
          $fb_id = $user_profile['id'];
          $gender = $user_profile['gender'];
    
    
    
           $SrcUser = mysql_query("SELECT * FROM users WHERE fb_id = '" . $fb_id . "'") or die(mysql_error());
          $CheckDB = mysql_num_rows($SrcUser);
    
          if($CheckDB == 1){
              // If user has an account
    
              while ($row = mysql_fetch_array($SrcUser)) 
                    { 
                         $id = $row["id"];
                         $user_level = $row["user_level"];
                    }
            session_start();
            $_SESSION['user_name'] = $full_name;
            $_SESSION['user_level'] = $user_level;
            $_SESSION['user_id']= $id;  
            // Javascript redirect.. its kinda cheating to be honest as if i dont use it i will have awkwardness with header errors
            ?>
      <script type="text/javascript">
            window.location = "myaccount.php"
            </script>
            <?
          } else {
              // If user does not have an account create new
            ?>  <?
            session_start();
            $_SESSION['fb_id']= $fb_id;  
    
            if($gender == "male"){
                $gender = "1";
            } else {
                $gender = "0";
            }
            $_SESSION['r_full'] = $full_name;
            $_SESSION['r_gender'] = $gender;
    
            mysql_query("INSERT INTO users (full_name, gender, fb_id)
                VALUES ('$full_name','$gender','$fb_id')");
            $user_id = mysql_insert_id();  
            $md5_id = md5($user_id);
            mysql_query("update users set md5_id='$md5_id' where id='$user_id'");
    
                $md5_id = md5($user_id);
                mysql_query("update users set md5_id='$md5_id' where id='$user_id'");
    
            ?>
    

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am planning to integrate Login With Facebook feature into my iPhone/Android App; and
im planning to create a movie file that might have over 16,000 frames?i know
Possible Duplicate: HTML Compress File Upload? I have complains from client that my website
I am planning to develop a pretty awesome new web app that has a
Scenario: I have an application (C#) that expects a SQL database and login, which
I am planning to inegrate messaging middleware in my web application. Right now I
I have 2 exporter methods (planning to have more) that essentially take my sprite
I planning on reading profile data from a xml file in JSP. Now i
I'm currently planning a new web project. Clients are going to connect using a
My current class is planning on creating a basic networked game, but we have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.