I am new at this...so please bare with me.
Simple json call, looking for userdata = true in response
the set Name_Field.Text is not working.
Server side is pretty simple.
If I click the logoff button the IF statement for it works. But doing a json call and trying to get user data to the label on the screen doesn't work. I am wondering what it could be. I've hit beat my head on this for about 2 hours now.
<?php
session_start();
include "./helpers/functions.php";
// Takes raw data from the request
$json = file_get_contents('php://input');
// Converts it into a PHP object
$data = json_decode($json);
$jsonArr = array();
openlog("myScriptLog", LOG_PID | LOG_PERROR, LOG_LOCAL0);
if($data->logoff == true){
$sql = "SELECT * FROM users WHERE app_key = '".$data->app_key."';";
$info = dbread($sql);
if(isset($info[0])){
syslog(LOG_WARNING, "log off request - userid = ".$data->app_key);
$jsonArr['logoff'] = true;
}
else{
syslog(LOG_WARNING, "no user found possible false request- ".$data->app_key);
$jsonArr['logoff'] = false;
}
//send json response
$jsonSend = json_encode($jsonArr);
echo $jsonSend;
}
if($data->userinfo == true){
$sql = "SELECT * FROM users WHERE app_key = '".$data->app_key."';";
$info = dbread($sql);
if(isset($info[0])){
syslog(LOG_WARNING, "getting user data- ".$data->app_key);
$jsonArr['userdata'] = true;
$jsonArr['first'] = $info[0]['first'];
$jsonArr['last'] = $info[0]['last'];
$jsonArr['email'] = $info[0]['email'];
$jsonArr['phone'] = $info[0]['phone'];
}
else{
syslog(LOG_WARNING, "no user found possible false request- ".$data->app_key);
$jsonArr['appdata'] = false;
}
//send json response
$jsonSend = json_encode($jsonArr);
echo $jsonSend;
}
closelog();
?>