title: Statement to tell me the username already exists
body: <p>The below query is not telling me the username already exists in the database even though it does.</p>
  
  <p>I am trying to learn how to bind parameters etc. but have confused myself somewhere I think.</p>
  
  <pre><code>&lt;?php
      // Include config.php
      require_once("".$_SERVER['DOCUMENT_ROOT']."/admin/config.php");
  
      // top.inc.php
      require_once($top_inc);
  ?&gt;
  
  &lt;!-- Meta start --&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;meta name="description" content="" /&gt;
  &lt;meta name="keywords" content="" /&gt;
  &lt;!-- Meta end --&gt;
  
  &lt;!-- CONTENT START --&gt;
  
  &lt;?php
      // sidebar.inc.php
      require_once($sidebar_inc);
  
      // main.inc.php
      require_once($main_inc);
  
      // check if form has been submitted
      if($_SERVER['REQUEST_METHOD'] == 'POST' &amp;&amp; isset($_POST['submit'])){
  
          // initialize form errors array
          $error    = array();
  
          // fetch form data
          $username = $_POST['username'];
          $email    = $_POST['email'];
          $password = $_POST['password'];
  
          // validate form data
          if(!preg_match(constant("USERNAME_REGEX"), $username)){
              $error[] = "Please enter a username. Use 3 to 15 digits and letters";
          }
          if(!preg_match(constant('PASSWORD_REGEX'), $password)){
              $error[] = "Please enter a password. Minimum of 6 characters required";
          }
          if(!empty($password) &amp;&amp; $password == $username){
              $error[] = "Your pasword cannot be you username for security reasons";
          }
          if(empty($email)){
              $error[] = "Please enter your email address";
          }
          if(!empty($email) &amp;&amp; !filter_var($email, FILTER_VALIDATE_EMAIL)){
              $error[] = "Your email address is not valid";
          }
  
          // connect to database
          sql_con();
  
          // Get instance of statement
          $stmt = mysqli_stmt_init($connect);
  
          // sql statement
          $UserExists = "
                      SELECT
                          `user_login`
                      FROM
                          `users`
                      WHERE
                          `user_login` = ? ";
  
          // prepare sql statement for execution
          if (mysqli_stmt_prepare($stmt, $UserExists)) {
  
              // bind parameters [s for string]
              mysqli_stmt_bind_param($stmt, "s", $username) or die(mysqli_stmt_error());
              // execute statement
              mysqli_stmt_execute($stmt) or die(mysqli_stmt_error());
              // check if username is found
              if(mysqli_stmt_num_rows($stmt) &gt; 0 ){
                  $error[] = 'The username you have choose has already been taken';
              }
          }
  
          // If errors found display errors
          if(!empty($error)){
              foreach($error as $msg){
                  echo "$msg &lt;br /&gt;";
              }
      } else {
              echo 'My Query Worked!';
          }
      }
      // signup.tpl template location
      $tpl = 'inc/tpl/signup.tpl';
      // load signup form template
      PageContentTemplate($tpl);
  ?&gt;
  
  &lt;!-- CONTENT FINISH --&gt;
  
  &lt;?php
      // footer.inc.php
      require_once($footer_inc);
  ?&gt;
  </code></pre>
  
  <p>Basically it just echos out 'My Query Worked' even though it should say the username is already taken which it is, I enter details on the form and a username I know that has been taken and submit the form, I know I am doing something probably really silly but being new to mysqli and binding parameters etc. I don't know where I am going wrong even though I have looked at some examples.</p>
  
  <p>To be honest, I am not sure if this is the best way to do it in procedural style, I don't know PDO/OOP, my main reason to change is to avoid SQL injection by using placeholders etc. in my queries.</p>