The errors help to improve coding skills. You are getting a fatal error: Call to a member function. I tried your code and reviewed Create a blog using PHP and MYSQL database the article link. I think you are getting an issue with your connection file.
define('DBHOST','localhost');
define('DBUSER','root');
define('DBPASS','');
define('DBNAME','db_name');
$db = new PDO("mysql:host=".DBHOST.";dbname=".DBNAME, DBUSER, DBPASS);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$user = new User($db);
//set timezone- Asia Kolkata
date_default_timezone_set('Asia/Kolkata');
$user = new User($db);
You should check your connection details. If you have any other issues, comment here.