I am creating a user system that shows the profile of each one, I only show mine and the main objective is to see the other profiles of all registered users, something similar to facebook, try to do it with sessions and according to the id of the BBDD, but only show my information always.
public function author(){
try{
if($_SESSION['id_user']!=$_SESSION['author']){
$read_user = $this->BBDD->prepare("SELECT * FROM usuarios WHERE id = ?");
$read_user->execute(array($_SESSION['author']));
$read_response = $read_user->fetchAll(PDO::FETCH_OBJ);
$this->BBDD = NULL;
//header("location:../dashboard.php");
return $read_response;
}
//$this->id_author = $_SESSION['id'];
} catch (PDOException $ex) {
die("Error al leer este usuario" . $ex->getCode() . PHP_EOL . " " . $ex->getMessage() . PHP_EOL . $ex->getLine());
}
}
This code does not work for me since the user always has to take an action to create the author variable, and what I really want is to only show his profile from other users and not mine.