Always use prepare Statements to avoid SQL injectrion Use a try-catch block around the “new pdo()” statement to catch the full exception thrown by it if it failed to connect. It would then print all the login details including username and password which is not good.
Transactions
Use transactions to safely execute multiple SQL statements at once and rollback all statements if any error occurs to avoid inconsistent data