无形FB注册

时间:2013-10-10 22:38:12

标签: php mysql pdo

所以我使用PHPSDK进行FB连接。对于初学者我是这样做的,当用户注册时,它会自动创建他们的个人资料(个人资料,姓名,年龄,性别,工作/雇主,电子邮件等)。

所以效果很好,只需点击一下即可创建个人资料。

但是我试图这样做,当用户点击“使用Facebook注册”按钮时,它还会在后台将用户数据存储在后端。我是否必须通过提交表单按钮并将下面的所有变量定义为$ _POST来存储它? (我正在使用PDO / MySQL,参见下面的例子

我尝试了以下但不起作用。

$user = "xxxx";
$pwd = "xxxx";

$odb = new PDO("mysql:host=localhost;dbname=xxxx;", $user, $pwd);

$q = "INSERT INTO users(u_fullname, age, u_location, u_gender, u_bday, u_employer, u_job) VALUES(:u_fullname, :age, :u_location, :u_firstname, :u_gender, :u_bday, :u_employer, :u_job)";
$query = $odb->prepare($q);
$results = $query->execute(array(":u_fullname" => $u_fullname, ":age" => $age, ":u_location" => $u_location, ":u_gender" => $u_gender, ":u_bday" => $u_bday, ":u_employer" => $u_employer, ":u_job" => $u_job));

这是个人资料设置

<? $fbuid = $user_profile['id'];
$u_employer = $user_profile['work'][0]['employer']['name'];
$u_job = $user_profile['work'][0]['position']['name'];
$u_firstname = $user_profile['first_name'];
$u_fullname = $user_profile['name'];
$u_location = $user_profile['location']['name'];
$u_gender = ucfirst($user_profile['gender']);
$u_bday = $user_profile['birthday'];
//explode the date to get month, day and year
$u_bday = explode("/", $u_bday);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $u_bday[0], $u_bday[1], $u_bday[2]))) > date("md") ? ((date("Y")-$u_bday[2])-1):(date("Y")-$u_bday[2]));?>

非常感谢任何帮助!

0 个答案:

没有答案