This is the code for my function
public function getuserData() {
session_start();
$username = $_SESSION['user'];
$getData = $this->db->prepare("SELECT * FROM users WHERE username=?");
$getData->bindParam(1, $username);
$getData->execute();
$row= $getData->fetch(PDO::FETCH_ASSOC);
$email = $row['email'];
$user = $row['username'];
echo $email. '<br />';
echo $user;
}
<?php
require_once "class/user.php";
echo $user;
echo $email;
$object = new User();
$object->getUserData();
?>
and here is my home.php, the username, and email echo out but only from the function, if i try to do echo $email;
on the home.php it doesn't print. I need to print it out on the home page so I can style the output.
Already tried starting session on home.php
and it still doesn't work, as I already started it in the getUserData()
function.