Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法使用从facebook登录获取的数据(使用php和js)更新sql server_Javascript_Php_Facebook Login - Fatal编程技术网

Javascript 无法使用从facebook登录获取的数据(使用php和js)更新sql server

Javascript 无法使用从facebook登录获取的数据(使用php和js)更新sql server,javascript,php,facebook-login,Javascript,Php,Facebook Login,尝试了一点,但无法检测到错误,我想要的是,当用户访问我的网站并使用facebook登录登录时,他的用户数据必须添加到我的网站数据库中 下面是客户端js代码,它工作正常并从Facebook获取数据,我通过打印获取的详细信息进行验证。但在将AJAX添加到post到php文件后,甚至“感谢登录”消息也不会打印出来 function testAPI() { console.log('Welcome! Fetching your information.... '); var url = '/me?f

尝试了一点,但无法检测到错误,我想要的是,当用户访问我的网站并使用facebook登录登录时,他的用户数据必须添加到我的网站数据库中

下面是客户端js代码,它工作正常并从Facebook获取数据,我通过打印获取的详细信息进行验证。但在将AJAX添加到post到php文件后,甚至“感谢登录”消息也不会打印出来

function testAPI() {
console.log('Welcome!  Fetching your information.... ');
 var url = '/me?fields=name,email';
         FB.api(url, function (response) {  //over here i used this to obtain email explicitly
             var fbname=response.name;
             var mail=response.email;
             $.ajax({
             type: "POST",
             url: "http://kumarindia.byethost24.com/addguestbook.php",
             data: "name="+fbname+"&email="+mail,
                 });
   document.getElementById('status').innerHTML =
    'Thanks for logging in, ' + response.name  +"," + response.email + '!';
});
}
下面是服务器端php文件

$name = mysqli_real_escape_string($con, $_POST['name']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$comment = mysqli_real_escape_string($con, $_POST['comment']);


$sql="INSERT INTO questbook (name, email, comment, datetime)
VALUES ('$name', '$email', '$comment', '$datetime')";

if (!mysqli_query($con,$sql)) {
 die('Error: ' . mysqli_error($con));
}

尝试使用对象而不是查询字符串:
数据:{name:fbname,email:mail}
并删除尾随的逗号。如果php文件有注释参数,但对象不提供它,它会影响吗?可能是,是。你应该检查一下。示例:
$comment=isset($\u POST['comment'])?mysqli_real_escape_string($con,$_POST['comment']):''您认为是什么阻止了“感谢登录…”消息的显示所有更改,但数据库中仍然没有更改