Welcome Guest, Not a member yet? Register   Sign In
How to store facebook user data into database ?
#7

[eluser]Keloo[/eluser]
I've tried something like this:

in the model I'm checking for the id

Code:
public function id_check($id)
{
  $this->db->where('id', $id);
  return $this->db->get('users')->num_rows();
}

and in the controller have something like this:
Code:
function account()
{
  $fb_data = $this->session->userdata('fb_data');

  if((!$fb_data['uid']) or (!$fb_data['me']))
  {

   redirect('home/index');
  }
  else if($this->Facebook_model->id_check($fb_data['me']['id']) < 0 )
  {
   $query = array(
    'id' => $fb_data['me']['id'],
    'fullname' => $fb_data['me']['name'],
    'email' => $fb_data['me']['email']
   );

   $this->db->insert('users',$query);
  
  }
  else
  {
  
   $data = array(
      'fb_data' => $fb_data

    );

   $this->layouts->set_title('My Account');
   $this->layouts->view('account', $data);
  }

}

The problem is, when I'm logging in with another fb account, it doesn't grab the user data and insert it in the DB, because there is data.

I need to check by id. If that ID already exists, don't insert data, but if it doesn't insert it.



Messages In This Thread
How to store facebook user data into database ? - by El Forum - 05-23-2012, 02:10 AM
How to store facebook user data into database ? - by El Forum - 05-23-2012, 02:33 AM
How to store facebook user data into database ? - by El Forum - 05-23-2012, 03:54 AM
How to store facebook user data into database ? - by El Forum - 05-24-2012, 01:44 AM
How to store facebook user data into database ? - by El Forum - 05-24-2012, 03:28 AM
How to store facebook user data into database ? - by El Forum - 05-24-2012, 06:32 AM
How to store facebook user data into database ? - by El Forum - 05-24-2012, 08:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB