PHP login with PDO, doesnt seem to work <p>There aren't any errors given, but for some reason the code doesnt seem to work..</p> <p>Here is the code:</p> <pre><code>&lt;?php session_start(); require_once('inc/db.php'); if(isset($_SESSION['username'])) { header("location: index.php"); } else { try { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $SQL = $dbh-&gt;prepare('SELECT * FROM users WHERE username =:username AND password =:password'); $SQL-&gt;bindParam(':username', $username); $SQL-&gt;bindParam(':password', $password); $SQL-&gt;execute(); $total = $SQL-&gt;rowCount(); $row = $SQL-&gt;fetch(); if($total &gt; 0) { if($row['verified'] &gt; 0) { $_SESSION['username'] = $username; } else { echo "Unverified"; } } else { echo "Incorrect"; } } catch(PDOException $e) { } } ?&gt; </code></pre> <p>Can anyone help me see what's wrong? Thank you a lot in advance :)</p> <p>EDIT::::</p> <p>Here is my db.php</p> <pre><code>&lt;?php try { $DB_NAME = 'users'; $DB_USER = 'root'; $DB_PASS = ''; $dbh = new PDO('mysql:host=localhost;dbname='.$DB_NAME, $DB_USER, $DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; "SET NAMES utf8")); $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo "Error?"; } ?&gt; </code></pre>