Use Volley to do POST request to a url that returns user data ... But to see this data, creating a simple html form with action set for the url 192.168.0.101/project/user.php. Hi, I have a JSON application that I want to use. NOTE: I used header ("Location: www.teste.com"); and redirects without showing the JSON to the possible "hacker" BUT does not list the data in the app
PHP:
<?php
require_once('config.php');
require_once 'classes/BD.class.php';
BD::conn();
if(isset($_POST['user']) && $_POST['user'] != ""){
$user = (int)$_POST['user'];
$searchPhotos = BD::conn()->prepare("SELECT * FROM 'photos' WHERE 'id_user' = ? ORDER BY 'id' DESC");
$searchPhotos->execute(array($user));
$resultPhotos = $searchPhotos->rowCount();
$searchQtdFollowers = BD::conn()->prepare("SELECT id FROM 'follows' WHERE 'user' = ?");
$searchQtdFollowers->execute(array($user));
$resultFollowers = $searchQtdFollowers->rowCount();
$searchQtdFollowing = BD::conn()->prepare("SELECT id FROM 'follows' WHERE 'follower' = ?");
$searchQtdFollowing->execute(array($user));
$resultFollowing = $searchQtdFollowing->rowCount();
$array = array(
"photos" => $resultPhotos,
"followers" => $resultFollowers,
"following" => $resultFollowing
);
$result[] = array_map("utf8_encode", $array);
while($data = $searchPhotos->fetch(PDO::FETCH_ASSOC)){
$array = array(
"photo" => PATH.$data["photo"],
"date_creation" => date('d/m/Y', strtotime($data["date_creation"]))
);
$result[] = array_map("utf8_encode", $array);
}
header('Content-type: application/json');
echo json_encode($result);
}
?>