我有一个 facebook 应用程序,我需要在其中获取用户的 ID、姓名、电子邮件和他提交的输入值发送到数据库。出于某种原因,我不知道数据没有被发送。我尝试在 saveuser.php 中回显变量,但我只得到输入值。我在控制台中也没有收到任何错误。我的怀疑是它与 AJAX 功能有关:
编辑 :
FB.login(function(response)
{
console.log(response);
if (response.status=="connected")
{
console.log("You're logged in");
FB.api('/me', function(response)
{
$.ajax({
type: 'POST',
url: 'saveuser.php',
data: {
name = response.name,
fbid = response.id,
email = response.email
};
});
});
}
});
保存用户.php:
require('config.php');
if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['fbid']))
{
$fbid = mysql_real_escape_string($_POST['fbid']);
$name = mysql_real_escape_string($_POST['name']);
$email = mysql_real_escape_string($_POST['email']);
$receipt = mysql_real_escape_string($_POST['receipt']);
addUser($name, $email, $fbid, $receipt);
}
function addUser($name, $email, $fbid, $receipt)
{
$query = "SELECT id FROM rkiosk_monster_users WHERE fbid = '$fbid' LIMIT 5";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if ($rows == 0)
{
$query = "INSERT INTO rkiosk_monster_users (name, email, fbid, receipt) VALUES ('$name', '$email', '$fbid', '$receipt')";
}
mysql_query($query);
}
任何帮助,将不胜感激。