In your public function ConnessioneDB() in the Database classs you need to return the connection
class Database
{
private $host = "localhost";
private $nome_db = "GED";
private $username = "root";
private $password = "root";
public $conn;
public function ConnessioneDB()
{
$this->conn = null;
try
{
$this->conn = new PDO("mysql:host=".$this->host.";dbname=".$this->nome_db, $this->username,$this->password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->conn->exec("SET NAMES utf8");
return $this->conn;
}
catch(PDOException $e)
{
echo "<div id='error-top'>Si è verificato un errore di connessione.</div>";
}
}
}
If you do not return the connection the $conn property in your User class will be null. Thus you get this error.