title: Check user credentials PHP MySQL
body: <p>Im trying to create a user management section on my website that allows users to login. </p>
  
  <p>So far I have the following PDO Conenction class...</p>
  
  <pre><code>    &lt;?php 
  
  class connection{
  
  private $host = 'localhost';
  private $dbname = 'dbname';
  private $username = 'liam@';
  private $password ='Password';  
  
  public $con = '';
  
  function __construct(){
  
      $this-&gt;connect();   
  
  }
  
  function connect(){
  
      try{
  
          $this-&gt;con = new PDO("mysql:host=$this-&gt;host;dbname=$this-&gt;dbname",$this-&gt;username, $this-&gt;password);
          $this-&gt;con-&gt;setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  
  
      }catch(PDOException $e){
  
          echo 'We\'re sorry but there was an error while trying to connect to the database';
          file_put_contents('connection.errors.txt', $e-&gt;getMessage().PHP_EOL,FILE_APPEND);
  
      }
  }   
  }
  
  ?&gt;
  </code></pre>
  
  <p>My check-login.php looks like...</p>
  
  <pre><code>&lt;?php
  
  include 'assets/connection.class.php';
  
  
  $username=$_POST['username']; 
  $password=$_POST['password'];
  
  
  function login(PDO $db, $username, $password) {
  $user_id = user_id_from_username($db, $username);
  $password = md5($password);
  $stmt = $db-&gt;prepare('SELECT COUNT(`user_id`) FROM `users` WHERE `username` = ? AND `password` = ?');
  $stmt-&gt;bindParam(1, $username);
  $stmt-&gt;bindParam(2, $password);
  $stmt-&gt;execute();
  if($stmt-&gt;fetchColumn() &gt; 0) {
      return $user_id;
  } else {
      return false;
      echo 'failed';
  }
  }
  ?&gt;
  </code></pre>
  
  <p>my problem is that im not given any result from check-login.php? Im not a php programmer so apologies if this seems vague, any help will be appreciated</p>