Good evening, I'm implementing a very basic facebook login system on my site, the system should capture the user's basic data (id, name and email) and save it to a table and that's where I'm having difficulties, already I ran around many forums on the internet and tested several codes, but nothing is working.
UPDATING
"I solved the problem by inserting the function.php data inside fbconfig.php, probably the code should be very heavy, but for the time being it worked:
fbcongig.php
<?php
session_start();
// added in v4.0.0
require_once 'autoload.php';
require 'dbconfig.php'; // Conexão com o Banco
...
/* ---- Session Variables -----*/
$_SESSION['FBID'] = $fbid;
$_SESSION['FULLNAME'] = $fbfullname;
$_SESSION['EMAIL'] = $femail;
/* ---- header location after session ----*/
if ($fbid>"1"){
$consulta = "SELECT Fuid FROM Users WHERE Fuid='".$fbid."'";
$check = mysqli_query($con,$consulta);
$numeros = mysqli_num_rows ($check);
if ($numeros <= 0){
$query = "INSERT INTO Users (Fuid,Ffname,Femail) VALUES";
$query .= "('".$fbid."','".$fbfullname."','".$femail."')";
$inserir = mysqli_query($con,$query) or die(mysql_error($con));
}
}
//checkuser($fbid,$fbfullname,$femail);
header("Location: index.php");
} else {
$loginUrl = $helper->getLoginUrl(array('scope' => 'email, public_profile,user_friends'));
header("Location: ".$loginUrl);
}
?>