dongshi1148 2017-08-23 04:24
浏览 73

状态页面显示特定Facebook帐户选择的选项

I would like to ask question. My condition now is like that, my user login into my android application with using facebook and after login they will go to the page which is allow them to select item. After select the item, they will view their selection in status page. In the status page , every account only will see their selection only. Now my one is every account selection will display together in status page and what i want is every account's status page will display their selection only. I am using localhost and php to write selection page and status page code. So, how i can do to make my application know which facebook user login to my app since i don't has login php.

Below is my selection and status page php

Selection page:

<?php 

if($_SERVER['REQUEST_METHOD']=='POST'){

//Getting values
$username = $_POST['username'];

$name = $_POST['name'];
$date = $_POST['date'];
//Creating an sql query
$sql = "INSERT INTO Selection (username, name, date) VALUES 
('$username','$name', '$date')";

//Importing our db connection script
require_once('dbConnect.php');

//Executing query to database
if(mysqli_query($con,$sql)){

     echo 'Select Successfully';
}else{
echo 'Sorry, You Are Select This Item Before';
}

//Closing the database 
mysqli_close($con);
}
?>

Status Page:

  <?php 
 //Importing Database Script 
 require_once('dbConnect.php');

 //Creating sql query
 $sql = "SELECT * FROM Selection" ;

 //getting result 
 $r = mysqli_query($con,$sql);

 //creating a blank array 
 $result = array();

 //looping through all the records fetched
 while($row = mysqli_fetch_array($r)){

//Pushing name and id in the blank array created 
array_push($result,array(
"id"=>$row['id'],
"username"=>$row['username'],
"name"=>$row['name'],
"date"=>$row['date']
));
}

//Displaying the array in json format 
echo json_encode(array('result'=>$result));

mysqli_close($con);

?>

Thank You.

  • 写回答

1条回答 默认 最新

  • dongtang7347 2017-08-23 04:36
    关注

    if you are using facebook login api for android then you can get the user id string from the AccessToken object returned from the success of login. This userid will uniquely identify the user on server. You can use it to know which user is currently logged in.

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号